How to use better GroupBy in LINQ ?

Hello everbody,

We often use LINQ. It is a very advanced query technology. I want to explain with one example.

First of all, our models;

Main part is:

Most basically, any buyer may has multiple basket, could put any product also each product could be multiple.

There are a buyer has in our example.

This buyer has 2 basket.

First basket has 2 products of the product number 1, 2 products of the product number 2 and 5 products of the product number 3.

Second basket has 5 products of the product number 2.

All items do group by productId. When we group with product id, result is products’ id and products’ quantitys.

Good luck.

This example on my github; https://github.com/taskinbinbir/LinqGroupByApp

You can follow my list about of Entity Framework and LINQ for more; https://taskinbinbir.medium.com/list/entity-framework-0a2b9ee4b7c3

Referance; https://github.com/dotnet-architecture/eShopOnContainers

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store