I have a 'Message' class:
public class User { public string Name { get;set; } /*Other properties*/ }
public class Message {
public User From { get;set; }
public ICollection<User> To { get;set; }
public string Title { get;set; }
/* Others */
}
And I have an index defined like so: (yes, straight out of the 'I've been following a tutorial video')
public class Message_ToFromTitle : AbstractIndexCreationTask
{
public override IndexDefinition CreateIndexDefinition()
{
return new IndexDefinition
{
Map = "from m in docs.Messages select new { Query = new[] { m.Title, m.From.Name, m.To.Select(r => r.Name), } }",
Indexes = {{"Query", FieldIndexing.Analyzed}}
};
}
}
Which in the Management Studio I can query quite successfully with things like Query:Chris
and it'll bring all Messages
with Chris in the 'To', 'From' or 'Title' which is great.
My problem is how do I query from .NET? I've tried:
session.Advanced.LuceneQuery<Message, Message_ToFromTitle>().Where("Query:Chris");
which works, but what I'd like to do is:
session.Query<Message, Message_ToFromTitle>().Where(m => m == "Chris");
But, raven (quite rightly) doesn't know what to do with 'm', as presumably I need to somehow query Query
.
Is the Advanced
route the only one open to me? I'm quite happy to change the Index definition, I've used the non-generic AbstractIndexCreationTask
as I'm doing a m.To.Select(r=>r.Name)
bit at the end which won't compile in C#, but is interpreted in the way I want in Raven, but will and would happily change to a generic one if needed!