NHibernate Projections, does it support projecting inner objects
Does Hibernate + NhibernateLINQ support projection of inner objects.
for eg. when I try the following I get an Index out of bounds exception on Patient object on the call to Queryable.ToList()
var registrations = from r in _session.Linq<Domain.Registration>().Expand("Patient") select r;
var queryable = registrations.Select(
r => new { r.Id, r.AccountNumber, r.DateAdded, r.DateUpdated, r.Patient.FamilyName, r.Patient});
var list = queryable.ToList();
var workListItems = new List<WorkListItem>();
foreach (var anonymous in list)
{
var w = new WorkListItem
{
Id = anonymous.Id,
ClientAccountId = anonymous.AccountNumber,
开发者_如何转开发 DateAdded = anonymous.DateAdded,
DateUpdated = anonymous.DateUpdated,
Patient = anonymous.Patient
};
workListItems.Add(w);
}
return workListItems;
The legacy contrib provider has problems with this kind of query.
The new integrated provider in NHibernate 3 handles them without problems.
As of 2010-09-30, Alpha3 is quite stable (with most efforts directed to improving the Linq provider even more), and a GA release is expected before the end of the year.
精彩评论