0
criteria.CreateAlias("ChildObject", "c");
IProjection fullProjection = Projections.ProjectionList()
.Add(Projections.Property("Item"), "Item")
.Add(Projections.Property("c.SubItem"), "ChildObject.SubItem")
这对象具有性能项目和ChildObject。NHibernate的投影用空多到一
ChildObject有一个属性子项目。
NHibernate可以使用此投影来成功查询并列出所有具有ChildObject的对象。
但是,某些行上的ChildObject可以为null。这个预测似乎完全忽略了它们。他们从来没有让我的变压器。我认为NHibernate根据需要使这些预测在标准中不为空。
所以我虽然我可以做战胜它的方法:
Projections.Conditional(Restrictions.Eq("ChildObject", null), nullProjection, fullProection)
哪里nullProjection没有ChildObject预计为所有,但后来它只是抱怨....
Both true and false projections must return the same types.
有无论如何做这个投影,并获得可空值?或者我将不得不做两个单独的查询?