-
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
Query: Support GroupBy when it is final operator #19929
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
ef6-parity
type-enhancement
Milestone
Comments
ajcvickers
changed the title
Query: Client eval GroupBy when it is final operator
Query: Support GroupBy when it is final operator
Feb 18, 2020
This was referenced Mar 16, 2020
Closed
Merged
33 tasks
smitpatel
added a commit
that referenced
this issue
Sep 2, 2022
smitpatel
added
the
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
label
Sep 2, 2022
smitpatel
added a commit
that referenced
this issue
Sep 3, 2022
smitpatel
added a commit
that referenced
this issue
Sep 12, 2022
smitpatel
added a commit
that referenced
this issue
Sep 12, 2022
Works for me when grouping by a string, but is failing for me when grouping by int: var query = context.Books.GroupBy(s => s.Price);
public class Author
{
public int Id { get; set; }
public string Name { get; set; } = default!;
}
public class Book
{
public int Id { get; set; }
public Author Author { get; set; } = default!;
public int Price { get; set; }
}
public class SomeDbContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseSqlServer(Your.ConnectionString, b => b.UseNetTopologySuite())
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging();
public DbSet<Book> Books => Set<Book>();
public DbSet<Author> Authors => Set<Author>();
}
public class Program
{
public static void Main()
{
using (var context = new SomeDbContext())
{
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
var toast = new Author { Name = "Toast" };
var alice = new Author { Name = "Alice" };
context.AddRange(
new Book { Author = alice, Price = 10 },
new Book { Author = alice, Price = 10 },
new Book { Author = toast, Price = 12 },
new Book { Author = toast, Price = 12 },
new Book { Author = toast, Price = 14 });
context.SaveChanges();
}
using (var context = new SomeDbContext())
{
var query = context.Books.GroupBy(s => s.Price);
foreach (var group in query)
{
Console.WriteLine($"Price: {group.Key}; Count = {group.Count()}");
}
}
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
ef6-parity
type-enhancement
This issue is about enabling following query
This is NOT about client evaluating when there is any additional operator after GroupBy or result selector is specified in GroupBy.
Examples of disallowed queries where we will NOT client eval GroupBy operator
As of EF Core 3.1 certain constructs of GroupBy where GroupBy is composed over (followed by another queryable operator) is translated. Read our GroupBy operator documentation to understand what is supported scenarios.
There are few other cases, where GroupBy with composition can be translated to server but not yet translated. To list a few
Resolution of this issue only enables client evaluation of GroupBy when it is last operator. Any of the above listed missing features will not work even if this issue is fixed. Please upvote relevant issue from above list which you need in your scenario. Please upvote this issue iff you need client side evaluation of GroupBy operator when it is last operator.
The text was updated successfully, but these errors were encountered: