Nhibernate联表筛选的方法

http://stackoverflow.com/questions/12930477/nhibernate-could-not-resolve-property

QueryOver is not the same as the Linq query provider. It would be easier to do:

NHibernateSession.Query<Message>().Where(x => x.User.Name== name).ToList();

But if you want to use QueryOver, you will need to explicitly join the relationships you want to navigate:

NHibernateSession.QueryOver<Message>().JoinQueryOver(x => x.User)// navigate to the user on the relationship.Where(u => u.Name== name)// this restriction is on the User now.List();

you could also do this using an alias for user

posted @ 2013-03-01 10:00  ido  阅读(285)  评论(0编辑  收藏  举报