Reputation: 3951
On Nhibernate 3.2 I'm having trouble with a Linq Query:
var temp = Session.Query<RequestForQuotation>().OrderByDescending(o => o.DateIssued).ToList();
var temp2 = Session.Query<RequestForQuotation>().OrderByDescending(o => o.DateIssued).SelectMany(o => o.RequestForQuotationItems).ToList();
var temp3 = Session.Query<RequestForQuotation>().OrderByDescending(o => o.DateIssued).SelectMany(o => o.RequestForQuotationItems).Select(o => o.SupplierProduct).ToList();
temp3 throws exception
NHibernate.QueryException : could not resolve property: DateIssued of: XXXX.Domain.Entities.RequestForQuotationItem
obviously DateIssued is a property/column of RequestForQuotation not RequestForQuotationItem
Is this a known issue with Nhibernate Query or something wrong with my thinking? Is there a workaround?
Upvotes: 1
Views: 833
Reputation: 110111
Possible workaround (have no SelectMany)
Session.Query<RequestForQuotationItem>()
.OrderByDescending(i => i.RequestForQuotation.DateIssued)
.Select(i => i.SupplierProduct)
.ToList();
Upvotes: 0
Reputation: 3951
Possible workaround seems to be this, but I'm not sure about it:
Session.Query<RequestForQuotation>().SelectMany(o => o.RequestForQuotationItems, (rfq, rfqi) => new { rfq, rfqi }).OrderByDescending(o => o.rfq.DateIssued).Select(o => o.rfqi.SupplierProduct)
Upvotes: 1