I have a situation where I want to do a query by two fields, I thought this would be pretty simple, but it is proving a great deal more difficult than I thought.
This is a rough look at the document being queried...
class Item {
string Id { get; set; }
string Name { get; set; }
Origin Origin { get; set; }
}
class Origin {
string Id { get; set; }
string Name { get; set; }
}
There are other fields, of course. I am just listing the relevant ones. So my Index looks like this.
public class Item__ByName : AbstractIndexCreationTask<Models.Items.Item, Item__ByName.Result> {
public class Result {
public string Id { get; set; }
public string Name { get; set; }
public string Origin { get; set; }
}
public Item__ByName() {
Map = items => from item in items
select new Result {
Id = item.Id,
Name = item.Name,
Origin = item.Origin.Name
};
Index(i => i.Name, FieldIndexing.Analyzed);
Index(i => i.Origin, FieldIndexing.Analyzed);
}
}
And then I attempt to query it like this...
var results = RavenSession
.Query<Models.Items.Item, Indexes.Item__ByName>()
.Where(n => n.Name == name)
.Where(n => n.Origin.Name == origin)
.ToList();
but it keeps telling me that "Origin_Name" is not defined. I am really confused about why it is saying this, when I've very clearly defined it.