I have a domain like this:
class Project
{
...
Unit ProjectUnit
}
class Unit
{
...
IList<User> Users
}
class User
{
...
}
I have to get all projects based on one user, so: each Project where Unit.Users contain query user.
How can I translate this 开发者_Python百科to a DetachedCriteria?
This assumes you have an Id property on your User class and you're passing in a User user.
DetachedCriteria query = DetachedCriteria.For(typeof(Project),"Project")
.CreateCriteria("ProjectUnit","Unit")
.CreateCriteria("Users","users")
.Add(Expression.Eq("Id", user.Id));
精彩评论