我的实体是:RavenDB:如何使用多个搜索字词查询
class Resource
{
string Name;
string EmployeeId;
}
如何查询多个雇员的资源呢?我试过这个:
Resource[] FindResourcesByEmployees(string[] employeeIds)
{
return this.Session.Query<Resource>()
.Where(r => employeeIds.Contains(r.EmployeeId))
.ToArray();
}
但是,这给了我NotSupportedException:方法不支持:包含。然后我尝试以下方法:
Resource[] FindResourcesByEmployees(string[] employeeIds)
{
return this.Session.Query<Resource>()
.Where(r => employeeIds.Any(v => v == r.EmployeeId))
.ToArray();
}
这引发NotSupportedException:不支持表达式类型:System.Linq.Expressions.TypedParameterException。
在SQL它会是这样的:
SELECT * FROM resource WHERE employeeid IN (1, 2, 3)
我的问题是,我该如何执行RavenDB此查询?
这篇文章也许能帮助您http://stackoverflow.com/questions/4207739/linq-query-with-multiple-contains-any-for-ravendb – JonVD
不,这种情况下,实体本身包含一个集合。在我的情况下,只有查询包含一个集合,而实体不包含集合。 –