Skip to content

NH-3450 - Nested projections of subcollections with subcollections #1307

Open
@nhibernate-bot

Description

@nhibernate-bot

Mattias Viberg created an issue — 19th April 2013, 10:15:19:

The below mimcs the behaviour of the WCF Data Service query:

http://services.odata.org/Northwind/Northwind.svc/Shippers?$expand=Orders/Order_Details

It gets all Shippers and expands Shipper.Orders and Order.Order_Details (called OrderLines below). However it generates sql with a stray '.' which throws upon exection.

[Test]
		public void ProjectNestedSubcollections()
		{
		    var query = from s in db.Shippers
		                select new ExpandedWrapper<Shipper, IEnumerable<ExpandedWrapper<Order, IEnumerable<OrderLine>>>>
		                    {

		                        ExpandedElement = s,
		                        Description = "Orders",
		                        ReferenceDescription = "",
		                        ProjectedProperty0 = s.Orders.Select(x => new ExpandedWrapper<Order, IEnumerable<OrderLine>>
		                            {
		                                ExpandedElement = x,
		                                Description = "OrderLines",
		                                ReferenceDescription = "",
		                                ProjectedProperty0 = x.OrderLines
		                            })

		                    };
			var result = query.ToList();
		}

I thought this was the same bug as NH-3417 but after some investigation it seems more closely related to the closed NH-3385 (both related to NH-3333 though). However I thought it deserved an own issue.


Mattias Viberg added a comment — 25th April 2013, 11:22:16:

It seems that a subselect of a collection always generates a stray ".". If I remove the dot (with an interceptor), the query executes ok, but it failes to populate the OrderLines collection. I've provided a new test:

        [Test]
        public void ProjectNestedSubcollections2()
        {
            var query = from s in session.Query<Shipper>()
                        where s.ShipperId == 1
                        select new { Name = s.CompanyName, Orders = s.Orders.Select(o => new {o.OrderLines }) };
            var result = query.ToList();
            Assert.IsNotNull(result<0>.Orders.First().OrderLines);
        }

Mattias Viberg added a comment — 26th April 2013, 8:34:44:

A week has passed since I created the issue, and still no feedback whatsoever.This bug is a showstopper in our project and I would hate it if we had to throw out Nhibernate because of it. I've tried solving it myself but no luck yet. As I understand it the support for nested selects is only one level deep?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions