views:

29

answers:

2

I have two similar tables which have data I need to display in a single grid. As each table has slightly different fields, I decided to extract the data I need into a generic object that I can bind to the grid. Shown below are the expressions I am using. My question is, how can I modify or add code so that I can get a single list that I can bind to. I guess something along the lines of “var jobs = jobs1 + jobs 2” etc.

     var jobs1 = from j in ctx.MyImport.Include("MyMethod").Include("MySchedule")
                   select new
                   {
                       FileName = j.ImportFileName,
                       Name = j.Name,
                       ID = j.ImportID
                   };


     var jobs2 = from j in ctx.MyExport.Include("MyMethod").Include("MySchedule")
                   select new
                   {
                       FileName = j.ExportFileName,
                       Name = j.Name,
                       ID = j.ExportID
                   }
A: 

Take a look at the Union extension method: http://msdn.microsoft.com/en-us/library/bb341731.aspx

Stilgar
+3  A: 

You can use the extention method Concat:

var job3 = jobs1.Concat(jobs2);
sagie