Filter child collection returned with Aggregate Root using Nhibernate

后端 未结 4 1327
小蘑菇
小蘑菇 2021-01-13 08:46

I\'m trying filter the child collection of an aggregate root when loading it with Nhibernate. Load a Customer with all their Orders that have been shipped. Is this possibl

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-13 08:57

    ICriteria crit = session.CreateCriteria (typeof(Customer));
    
    crit.CreateAlias ("Orders", "o");
    crit.Add (Expression.Eq ("o.Status", shippedStatus));
    crit.Add (Expression.Eq ("Id", customerId));
    
    return crit.UniqueResult ();
    

    something like that.

提交回复
热议问题