Reputation: 1499
I am working on a project. I have the following Model
public class RegistrantClass : IRavenEntity
{
public RegistrantClass()
{
RegistrantId = new List<string>();
}
public int Id { get; set; }
public IList<String> RegistrantId { get; set; }
public String ClassId { get; set; }
}
And I have the following index defined
store.DatabaseCommands.PutIndex("RegistrantClass/ClassByStudents",
new IndexDefinitionBuilder<RegistrantClass>
{
Map = students => from i in students
from j in i.RegistrantId
select new { j }
});
I try to query the above index like so
public object GetMapping(string registrantId)
{
var mapping = _session.Query<RegistrantClass>("RegistrantClass/ClassByStudents")
.Customize(i => i.Include<RegistrantClass>(k => k.RegistrantId))
.Customize(i => i.Include<RegistrantClass>(k => k.ClassId))
.FirstOrDefault(m => m.registrantId.Contains(registrantId));
return mapping;
}
But then i get the Error Message
However that gives me NotSupportedException: Method not supported: Contains.
I tried with the following code
.FirstOrDefault(m => registrantId.In<string>(m.RegistrantId));
But then I get the following Error Message
Expression type not supported: System.Linq.Expressions.TypedParameterExpression
What could Me Be Doing Wrong. Kind Regards
Upvotes: 2
Views: 3276
Reputation: 22956
You need to do it the other way around:
Not:
.FirstOrDefault(m => registrantId.Contains(m.RegistrantId));
But:
.FirstOrDefault(m => m.RegistrantId.In(registrantId));
Upvotes: 7