当我尝试使用 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));
}
上课
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;
}
}
与映射,
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();
}
它抛出异常,
NHibernate.QueryException:无法解析属性:UserGroupID
如何解决财产问题?