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

--

--

--

Computer Engineer, Software Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Internationalization as Technical Debt

The Definitive Guide to being a Front end Web Developer in 2022

Meet the people fixing interop in healthcare at Lifen

Local SoDA initiatives: SoDA Breakfast and SoDA Locals

Configure Basic Authentication with Nginx

How does Google load balance requests?

LiDAR and glass devices for AR[2020]

GhostiFi — New PoC and Pseudocode

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
Taşkın Binbir

Taşkın Binbir

Computer Engineer, Software Developer

More from Medium

Looking for a way to initialize IOptions<T> manually?

Optimistic Concurrency in Code First Entity Framework Core

C# Programming Language: Hashtables

Adding Multiple Languages ​​with ASP.NET Core MVC