Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My question is for DataTable Related in c#

I have two data Tables both are having One common col. name ("PlkId"),
now one is having 100 records and other Table is having 50 records,
means remain 50 records are Actually Diff. Records,
I would like to store that 50 records in third Table ?

USING LINQ ( this is more importent ) i tried but not happening

I solved it bu using dataTable.select() method but want to know that can we do it through LINQ ?

Thanx in Advance :)

Amit Singh

Pune
Posted

1 solution

Here's some generic LINQ code that should work (you have to replace the column comparison stuff with appropriate values from your own code):

C#
var results = (from record in dataTable
               where record.column == somevalue
               select record).ToList();

...but I have to ask - why bother with LINQ when a simple and maintainable non-LINQ solution works fine and will probably be better performing beisdes? If this is for a work project, close the file and move on to the next task.
 
Share this answer
 
Comments
singh.amit777 16-Dec-11 6:05am    
Plz read my question -> i would like to copare two datatable and their diffr. value i need in third table . means i need to fire join using LINQ --> thank you again
singh.amit777 16-Dec-11 6:07am    
its not about Work Project friend :) i wanted to know why LINQ

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900