I am working on .NET 5 CORE app with Entity Framework Core 5.0.6 Version.

Ultimately, I need to group my record. In EF CORE 3, I was able to use group by on script before applying ToList() but I believe is not possible in EF Core 5. So to achieve group by, I am intended to pull record and then apply group by on it.. Unless there is a better way?

```
var contraventionImages = (from contravention in db.Contraventions
                  join contraventionGuideImage in db.ContraventionGuideImages on contravention.ContraventionId equals contraventionGuideImage.ContraventionId into con_guide_img
                  from contraventionGuideImages in con_guide_img.DefaultIfEmpty()
                  join image in db.GuideImages on contraventionGuideImages.GuideImageId equals image.GuideImageId into guide_img
                  from guideImages in guide_img.DefaultIfEmpty()
                  where contravention.ContraventionId == ContraventionId
                  select new ContraventionGuideImageView
                  {
                     Contravention = contravention,
                     ContraventionGuideImages = contraventionGuideImages,
                     GuideImages = guideImages
                  })
                  .FirstOrDefault()
                  ;

```

So I have pulled the record, ending script with FirstOrDefault(), now in second script where I am trying to inspect and group Item; is Unable to do so. I am not able to apply select on query result I have in previous step

[![enter image description here](https://i.stack.imgur.com/mmRtF.png)](https://i.stack.imgur.com/mmRtF.png)

```
 public class ContraventionGuideImageView
{
    public Contravention Contravention { get; set; }
    public ContraventionGuideImage ContraventionGuideImages { get; set; }
    public GuideImage GuideImages { get; set; }
}

```