Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: Double foreach

$
0
0
This is the code:


List<ReportArgs > list = new List<ReportArgs >();
List<Persons> persons = DB.Persons.AsNoTracking().AsParallel().OrderBy(o => o.IdPerson).ToList();
var Cars= DB.PersonCars.AsNoTracking().ToList().AsReadOnly();
               foreach (var item in persons )
                {

                    ReportArgs report= new ReportArgs();

                   report.Name = item.Name;
                   report.SeconName = item.SeconName;
                   report.Age = item.Age;

                foreach (var itm in Cars.Where(x => x.IdPerson == item.Idperson).ToList())
                    {
                        report.Cars  += itm.MatriculaAsociada.ToString();

                    }

                    list .Add(report);
                }
I have the following:

worksheet.Cell ("A2") = Value Report.GetDato(Id);

Once the report is presented gives me the following result

COLUMN A, COLUMN B COLUMN C COLUMNA D
Michael Robert 26 cared caryellow, carblue

But I need it to appear like this:

COLUMN A, COLUMN B COLUMN C COLUMNA D COLUMN E COLUMNA F
Michael Robert 26 carred caryellow carblue

Thanks.

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>