0

I'm trying to create an index from within RavenDB Studio for a collection named employee-tickets but I can't seem to find the correct syntax. Does anyone know the secret?

I've tried from t in docs["employee-tickets"] but that just complains with the following error:

Cannot apply indexing with [] to an expression of type

I know I could rename my entity but I simply don't want to :)

Vinney Kelly
  • 4,975
  • 1
  • 25
  • 31

2 Answers2

2

You sort of can, but it isn't recommended, you can use:

from doc in docs
where doc["@metadata"]["Raven-Entity-Name"] == "employee-tickets"
// rest of index

But I would recommend on using an identifier.

Ayende Rahien
  • 22,925
  • 1
  • 36
  • 41
1

I think that it is not a proper way to name a collection. Of course in .net you can't name an object with the "-" and then you can't have a collection with that name.

The syntax you could use is:

docs.CollectionName.Select(element => new {
    PropertyName = element.PropertyName
    .
    .
    .
})

OR

from element in docs.CollectionName
select new {
   PropertyName = element.PropertyName
}
Embri
  • 622
  • 3
  • 15
  • You bring up a valid point; it's not a CLS-compliant naming strategy. Though, in my case, I'm not using the .NET API at least not in the way which I'd need to reference the collection names in code. Thanks for posting this top on the `CollectionName` usage. – Vinney Kelly Aug 15 '17 at 19:04