I have 14 tables with some same columns name and types.I want to Export them to excel. How can I combine and Merge these common columns in one view Model in Entity Framework or Linq with One query ? now I query 14 tables separately and convert to list and add them to common list.
var listAll = new List<requestViewExcel>();
listAll.AddRange(r1);
listAll.AddRange(r2);
listAll.AddRange(r3);
listAll.AddRange(r4);
listAll.AddRange(r5);
listAll.AddRange(r6);
listAll.AddRange(r7);
listAll.AddRange(r8);
listAll.AddRange(r9);
listAll.AddRange(r10);
listAll.AddRange(r11);
listAll.AddRange(r12);
listAll.AddRange(r13);
listAll.AddRange(r14);
I don't like this Solution. is it another better way ?
I think you can use Concat()
var listAll = r1.Concat(r2).Concat(r3).Concat(...);
You can also use Union() but it will only return the unique items in the collections