我有域类位置
public abstract class BaseEntity<T> where T: struct
{
public virtual T Id { get; set; }
public virtual bool Equals(BaseEntity<T> other)
}
public class Location : BaseEntity<Int32>
{
public User User {get;set;}
}
public class User : BaseEntity<Int32>
{
public string Name {get;set;
}
public OtherInfo Otherinfo {get;set;};
}
public class OtherInfo
{
public string preference {get;set;};
}
var criteria = session.CreateCriteria(typeof(Location), "alias");
criteria.CreateCriteria("User", "user", JoinType.InnerJoin);
criteria.CreateCriteria("user.Otherinfo", "userInfo",JoinType.InnerJoin);
criteria.Add(Restrictions.Eq("user.Id", 100));
criteria.SetProjection(Projections.Alias(Projections.Id(), "Id"), Projections.Alias(Projections.Property("user.Name"), "Name"), Projections.Alias(Projections.Property("userInfo.preference "), "pref"));
现在当我执行上述标准时,它会在 userInfo.preference 上给出错误。{NHibernate.QueryException:无法解析属性:Otherinfo of:Location.User 这里有什么错误。是不是因为有多个嵌套对象