-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Warn for LastOrDefault without OrderBy #10493
Comments
Can you post the query? |
Sure, I've tried multiple versions: var samurai=_context.Samurais.LastOrDefault(s=>s.Name=="Sampson"); result in: |
p.s. the warning message is a result of me reporting this a year ago: #6929 |
Lack of order by is the cause of client eval. We are checking for Skip/Take/First. We should also issue warning for Last. (Single can be excluded since ordering may not matter) |
That makes a lot of sense. I'm just testing the methods so doing random things and in this case, I can now see that my randomness is illogical. |
Updating the issue to track adding the OrderBy warning for Last/LastOrDefault/etc. |
new title makes sense. thanks |
In: I don't get a clear message the exception is being caused by a missing
when executing this query: var manualQuery = context.Users.Select(dtoUser => new User.ViewDto
{
Id = dtoUser.Id,
Posts = dtoUser.Posts
.Select(
dtoPost => new Object_205617611___LastComment_Id_Text_UserId
{
__LastComment = dtoPost.Comments.LastOrDefault(),
Id = dtoPost.Id,
Text = dtoPost.Text,
UserId = dtoPost.UserId
})
.Select(
dtoLet => new Post.ViewDto
{
Id = dtoLet.Id,
LastComment = (dtoLet.__LastComment == null)
? null
: new Comment.ViewDto
{
Id = dtoLet.__LastComment.Id,
PostId = dtoLet.__LastComment.PostId,
Text = dtoLet.__LastComment.Text
},
Text = dtoLet.Text,
UserId = dtoLet.UserId
})
.ToList()
}).FirstOrDefault(x => x.Id == user.Id); Can this issue be re-opened for 3.0.0 or do I have to create a new issue? Reproduce repo: https://github.com/JoasE/AutoMapperRepro Moved from: #14991 |
LastOrDefault is still being evaluated locally and spits out a warning about it at runtime:
The LINQ expression LastOrDefault could not be translated and will be evaluated locally.
I'm not seeing evidence (searching in this repo, or listed on the roadmap) that it's on target to get implemented.
Any news?
The text was updated successfully, but these errors were encountered: