【发布时间】:2011-10-26 07:43:22
【问题描述】:
我的实体是:
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 中执行此查询?
【问题讨论】:
-
这篇文章可能对你有所帮助stackoverflow.com/questions/4207739/…
-
不,这种情况是关于实体本身包含一个集合。在我的例子中,只有查询包含一个集合,而实体不包含集合。
标签: ravendb