流畅的 nhibernate:查询多对多实体,相当于“any”;关键词
我在学生和教授(_students_selected)之间的数据库(带有桥接表)中建模了一对多关系,在我的实体中,我将其建模为多对多关系,即教授有许多学生。
HasManyToMany(x => x.Students)
.Table("_students_selected").ChildKeyColumn("student_key").ParentKeyColumn("professor_key");
public class Professor
{
private IList<Students> _students;
public virtual Student Students
{
get { return _students; }
set { _students = value; }
}
}
我无法查询教授学生,我已经尝试了以下方法,但是 nhibernate 无法识别任何内容来过滤列表。任何相当于什么?
_unitOfWork.Session.QueryOver<Professor>()
.Where(x => x.Students.Any(i => i.Id.IsIn(childStudentList))).List();
I have a mant-to-many relationship modeled in the database (with a bridge table) between Student and Professor (_students_selected) , in my entites i have modeled it as a many-to-many relationship i.e. a Professor has many Students.
HasManyToMany(x => x.Students)
.Table("_students_selected").ChildKeyColumn("student_key").ParentKeyColumn("professor_key");
public class Professor
{
private IList<Students> _students;
public virtual Student Students
{
get { return _students; }
set { _students = value; }
}
}
I am unable to query over the professors students, i have tried the following however nhibernate does not recognise Any to filter through the list. Whats the equivalent to any?
_unitOfWork.Session.QueryOver<Professor>()
.Where(x => x.Students.Any(i => i.Id.IsIn(childStudentList))).List();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这帮助我解决了类似的问题: nhibernate queryover没有急切地加载多对多连接别名
我能够将其减少到:
This helped me with a similar problem: nhibernate queryover not loading eagerly with a many to many joinalias
I was able to reduce it to: