我想用下面的語句來獲得與我後場的實體:NHibernate的AliasToBean變壓器協會
retVal = session.CreateCriteria(typeof(MyEntity))
.CreateAlias("MyEntityProperty", "MyEntityProperty")
.Add(Restrictions.Eq("MyEntityProperty.Year", year))
.SetProjection(
Projections.Distinct(
Projections.ProjectionList()
.Add(Projections.Property("Property1"), "Property1")
.Add(Projections.Property("Property2"), "Property2")
.Add(Projections.Property("MyEntityProperty.RegisteredUser"), "MyEntityProperty.RegisteredUser")
.Add(Projections.Property("MyEntityProperty.CompanyInfo"), "MyEntityProperty.CompanyInfo")
)
)
.SetResultTransformer(Transformers.AliasToBean(typeof(MyEntity)))
.List<MyEntity>()
.Cast<BaseMyEntity>();
myEntity所是我想要返回的實體,和MyEntityProperty是的屬性MyEntity是另一個實體(MyEntityProperty類型)。
我得到的錯誤是Could not find a setter for property 'MyEntityProperty.RegisteredUser' in class 'MyEntity'
是在AliasToBean變壓器不能處理子實體?或者還有什麼我需要做的,以使其工作?
FYI:https://github.com/nhibernate/nhibernate-core/pull/1534 – quetzalcoatl