我有一个传递给 NHibernate 的 linq 查询,Linq2NHibernate 将解析并返回我填充的实体。
string firstName = "Ryan";
Store store = _repository.Query<Store>().Where(x => x.Employees.Select(y => y.FirstName).Contains(firstName)).FirstOrDefault();
麻烦的部分是x => x.Employees.Select(y => y.FirstName).Contains(firstName)
这应该做的是选择员工姓名为 Ryan 的商店。
我在上面的行中收到一条错误消息,指出“未处理的表达式类型:1004 ”
在我看来,这是 Linq2NHibernate 的一个限制,并且.Select().Contains()
无法解析。
有任何想法吗?有没有其他人收到这个错误?我可以做些什么来修复它或解决它?
[编辑]
这是我最终使用的。
string firstName = "Ryan"
Store store = _repository.Query<Store>().Where(x => x.Employees.Any(y => y.FirstName == firstName)).FirstOrDefault();
Linq 查询是x => x.Employees.Any(y => y.FirstName == firstName)