When I try to execute the class below using ICriteria,
if (_userGroupId > 0 && _userId > 0 ) { return session.CreateCriteria(typeof(UserUserGroup)) .Add(Restrictions.Eq("UserGroupID", _userGroupId)) .Add(Restrictions.Eq("UserID", _userId)) .Add(Restrictions.Eq("Deleted", false)); }
for class
public class UserUserGroup { public virtual long UserUserGroupId { get; set; } public virtual long UserGroupId { get; set; } public virtual long UserId { get; set; } public virtual bool Deleted { get; set; } public UserUserGroup() {} public UserUserGroup(long userGroupId, long userId) { UserGroupId = userGroupId; UserId = userId; } }
with display
public void Override(AutoMapping<UserUserGroup> mapping) { mapping.Id(map => map.UserUserGroupId, "UserUserGroupID").GeneratedBy.HiLo("hibernate_unique_key", "next_hi", "100", "tablename='UserUserGroups'"); mapping.Map(map => map.UserId,"UserID").Nullable(); mapping.Map(map => map.UserGroupId,"UserGroupID").Nullable(); mapping.Map(map => map.Deleted,"Deleted").Nullable(); }
It throws an exception,
NHibernate.QueryException: Failed to resolve property: UserGroupID
How to get the property allowed?
source share