开发者

NHibernate Projections, does it support projecting inner objects

开发者 https://www.devze.com 2023-01-18 07:46 出处:网络
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()

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消