You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The usage of a .Select in a query seems to ignore the filtering that comes after it. In case of a .FirstOrDefault it will always return the first row in the table. In case of a .SingleOrDefault it will throw "Sequence contains more than one element" because it didn't filter.
var test = session
.Query<User>()
.Select(u => new UserProjection
{
Id = u.Id,
FirstName = u.FirstName,
LastName = u.LastName,
})
.FirstOrDefault(x => x.FirstName == "Han" && x.LastName == "Solo 3");
Might be related to this ticket: #3096 but this one does not involve a .Include. And also #3009 but with a FirstOrDefault in this case. We use this type of query with or without filtering, but reusing the projection.
The text was updated successfully, but these errors were encountered:
It's the same issue as #3009. Can you just do the Where() then Select() then FirstOrDefault() as the workaround? We don't yet do the expression lifting like Relinq did automatically. Tbh, I was surprised anyone did this just knowing how things work internally
The usage of a
.Select
in a query seems to ignore the filtering that comes after it. In case of a.FirstOrDefault
it will always return the first row in the table. In case of a.SingleOrDefault
it will throw "Sequence contains more than one element" because it didn't filter.Might be related to this ticket: #3096 but this one does not involve a
.Include
. And also #3009 but with a FirstOrDefault in this case. We use this type of query with or without filtering, but reusing the projection.The text was updated successfully, but these errors were encountered: