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

Query: SELECT subquery order condition is ignored when filtering #4955

Closed
gedsol opened this issue Apr 1, 2016 · 3 comments
Closed

Query: SELECT subquery order condition is ignored when filtering #4955

gedsol opened this issue Apr 1, 2016 · 3 comments
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

@gedsol
Copy link

gedsol commented Apr 1, 2016

The following code yields different results when executing against DBCollection and in-memory List of entities:

var query = ctx.Client.Select(c => new {
    client = c,
    ordersSorted = c.Orders.OrderByDescending(o => o.Date)
})
.Select(d => new {
    ClientId = d.client.Id,
    ClientName = d.client.Name,
    LastOrderDate = d.ordersSorted.FirstOrDefault().Date, // This works as intended
    LastCompletedOrderDate = d.ordersSorted.FirstOrDefault(o => o.Status == 5).Date, // Selected using OUTER APPLY without ORDER BY
    LastCancelledOrderDate = d.ordersSorted.FirstOrDefault(o => o.Status == 6).Date
});
var results = query.ToList();
@rowanmiller rowanmiller added this to the 1.0.0 milestone Apr 4, 2016
@rowanmiller rowanmiller modified the milestones: 1.0.1, 1.0.0 May 11, 2016
@rowanmiller rowanmiller changed the title LINQ to SQL SELECT subquery order condition is ignored when filtering Query: SELECT subquery order condition is ignored when filtering Jul 1, 2016
@rowanmiller rowanmiller removed the pri0 label Jul 6, 2016
@maumar maumar modified the milestones: 1.2.0, 1.1.0-preview1 Oct 5, 2016
@anpete
Copy link
Contributor

anpete commented Oct 18, 2016

Verified that we now generate the Order By.

@anpete anpete closed this as completed Oct 18, 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 18, 2016
@divega
Copy link
Contributor

divega commented Oct 18, 2016

@anpete then it got fixed for 1.1.0-preview1?

@anpete
Copy link
Contributor

anpete commented Oct 18, 2016

@divega Not sure when exactly, the bug is pretty old.

@divega divega modified the milestones: 1.1.0-preview1, 1.2.0 Oct 18, 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

6 participants