V
V
VM-032022-03-05 09:44:24
C++ / C#
VM-03, 2022-03-05 09:44:24

How to use nested loops in LINQ extension methods in c#?

There is a code that is written in pure LINQ

var array = from buyer in buyers
                from auto in autos
                where auto.Model == buyer.Model
                select new
                {
                    Name = buyer.Name,
                    Tel = buyer.Tel,
                    Brand = auto.Brand,
                    Model = auto.Model,
                    Year = auto.Year,
                    Color = auto.Color
                };


Is there a way to write this with extension methods?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2022-03-05
@VM-03

Nested from in is SelectMany
But in general what you have is clearly Join

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question