Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Converting Datatable To Xml Using Linq - Grouping & left outer join

$
0
0

Hello All,

I'm trying to run a Linq query on multiple data tables to produce a XML, filtered by Case_id . I'm following this example

Dataset to XML via Linq - Answered Fernando Soto - MCSD

I need left join "OtherDiag" table and it can have multiple or no records  per case. 

 var results = from dtE in ds.Tables["EOC"].AsEnumerable()
                              from dtPD in ds.Tables["PrinDiag"].AsEnumerable().GroupBy(t => t.Field<string>("case_id"))
                              from dtOD in ds.Tables["OtherDiag"].AsEnumerable().GroupBy(t => t.Field<string>("case_id")).DefaultIfEmpty()
                              select new { dtE, dtPD, dtOD };


Please help. I am dealing with millions of data, so it has to be fast processing also.  


Thanks for the help in advance.

LC


Viewing all articles
Browse latest Browse all 31927

Trending Articles



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