Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contains on Sub query with navigation and projection throws ArgumentException #4352

Closed
mikary opened this issue Jan 20, 2016 · 2 comments
Closed
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@mikary
Copy link
Contributor

mikary commented Jan 20, 2016

The following navigation test throws an ArgumentException: Property 'Int32 OrderID' is not defined for type 'Microsoft.Data.Entity.Storage.ValueBuffer'

        [ConditionalFact]
        public virtual void Where_subquery_on_navigation_with_projection()
        {
            using (var context = CreateContext())
            {
                var query = from p in context.Products
                            where p.OrderDetails.Select(od => new NonEntityType
                            {
                                OrderID = od.OrderID,
                                ProductID = od.ProductID,
                                Quantity = od.Quantity
                            }).Contains(new NonEntityType
                            {
                                OrderID = context.OrderDetails.FirstOrDefault().OrderID,
                                ProductID = context.OrderDetails.FirstOrDefault().ProductID,
                                Quantity = context.OrderDetails.FirstOrDefault().Quantity
                            })
                            select p;

                var result = query.ToList();

                Assert.Equal(1, result.Count);
            }
        }

        private class NonEntityType
        {
            public int OrderID { get; set; }
            public int ProductID { get; set; }
            public short Quantity { get; set; }
        }
@anpete
Copy link
Contributor

anpete commented Jan 25, 2016

Another repro:

from o in context.Orders
where (from od in context.OrderDetails
       where (from c in context.Set<Customer>()
              where c.CustomerID == o.CustomerID
              select c).First().Country
             == (from o2 in context.Set<Order>()
                 join c in context.Set<Customer>() on o2.CustomerID equals c.CustomerID
                 where o2.OrderID == od.OrderID
                 select c).First().Country
       select od).Count() > 0
select o;

@mikary
Copy link
Contributor Author

mikary commented Apr 28, 2016

The first query (Where_subquery_on_navigation_with_projection) is still throwing an ArgumentException but the message is now An item with the same key has already been added.
Exception is thrown from RelationalQueryModelVisitor.RegisterSubQueryVisitor

The additional repro from @anpete does not appear to fail (query compiles and runs but does not terminate in a reasonable amount of time due to the number of store commands).

@rowanmiller rowanmiller modified the milestones: 1.0.1, 1.0.0 May 9, 2016
@rowanmiller rowanmiller removed the pri0 label Jul 6, 2016
@maumar maumar modified the milestones: 1.1.0, 1.1.0-preview1 Oct 5, 2016
@anpete anpete closed this as completed Oct 11, 2016
@anpete anpete added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed type-investigation labels Oct 11, 2016
@rowanmiller rowanmiller modified the milestones: 1.1.0, 1.1.0-preview1 Oct 12, 2016
@ajcvickers ajcvickers modified the milestones: 1.1.0-preview1, 1.1.0 Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

5 participants