-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Milestone
Description
In current EF Core code, most queries are written like this
List<Blog> blogs = await context.Blogs.Where(b => something).ToListAsync(cancellationToken);
The problem I see with this approach is that List<T>
implies an order of the elements, although the database does not guarantee an order as long as there is no OrderBy()
in the query.
I know that this pattern is well established and it might be impossible to change it.
However to allow to better express that there is no order, I would like to see another extension method ToHashSetAsync()
.
Then one could write a query like this
HashSet<Blog> blogs = await context.Blogs.Where(b => something).ToHashSetAsync(cancellationToken);
This would better express that there is no ordering to all consumers of the blogs
collection.
MizardX, rhodon-jargon and ahmed-abdelrazek