0
public class Cat
{
    public int Id { get; set; }
    public string Name { get; set; }    
    public Breed Breed { get; set; }
}

public class Breed
{
    public int Id { get; set; }
    public string Name { get; set; }
}

How to GroupBy a DbSet of Cat by Breed.Name using EF Core? Both queries below fail to be translated:

var cats = _context.Set<Cat>();
cats.GroupBy(x => x.Breed.Name);
cats.Select(x => new { x, x.Breed.Name })
    .GroupBy(x => x.Name);
Nick Farsi
  • 366
  • 4
  • 19
  • What EF Core are you using? The line `cats.GroupBy(x => x.Breed.Name)` should be fine, though it does nothing so it won't be translated... is this actual code you tried? – NetMage Nov 23 '22 at 19:09

0 Answers0