我使用NHibernate
和下面創建查詢: -的NHibernate的ICriteria返回空結果
ICriteria criteria = session.CreateCriteria<PayinoutBookentry>();
ProjectionList projList = Projections.ProjectionList();
projList.Add(Projections.GroupProperty("PaymentOption").As("PaymentOption"));
criteria.SetProjection(projList);
criteria.SetResultTransformer(Transformers.AliasToBean<PayinoutBookentry>());
IList<PayinoutBookentry> payinoutBookentryList = criteria.List<PayinoutBookentry>();
POCO:
public class PayinoutBookentry
{
public virtual int PayinoutBookentryId { get; set; }
public virtual Methodofpayment PaymentOption { get; set; }
}
映射:
public PayinoutBookentryMap()
{
Table("payinout_bookentry");
Schema("test");
Lazy(true);
Id(x => x.PayinoutBookentryId, map => {
map.Column("PAYINOUT_BOOKENTRY_ID");
map.Generator(Generators.Native); });
ManyToOne(x => x.PaymentOption, map =>
{
map.Column("PAYMENT_OPTION");
// map.NotNullable(true);
map.Cascade(Cascade.None);
});
但是,當我試圖讓列表我只在列表中獲得一行,並且該行有空對象。
有人能讓我讓GroupProperty
有什麼問題嗎?因爲沒有GroupProperty
它工作正常。