Hello.
I have two tables: Requests and Users.
Table Request:
- Id
- Text
- UserId
Table User
- Id
- Name
So the map-file of Request contains the string
Code:
<many-to-one name="User" column="UserId">
Now I need to get all Requests where Usert = null or User.Name = ''
How can I do this by using the Criteria?
If I write this:
Code:
ICriteria c = session.CreateCriteria.(typeof(Request));
c.Add(Expression.Or(Expression.IsNull("User"), Expression.Eq("User.Name", "")));
IList il = c.List();
I send so exception:
could not resolve property: User.Name of: RequestIf I add the Alias:
Code:
ICriteria c = session.CreateCriteria.(typeof(Request));
c.CreateAlias("User", "user_");
c.Add(Expression.Or(Expression.IsNull("User"), Expression.Eq("user_.Name", "")));
IList il = c.List();
This code generate INNER JOIN with Users table, and Request with null-user is absent in selection.
Please, help.