Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 datatable and I need to create new datatable which should show the result as(datatable1 - datatable2).
For eg: datatable1 has IDs(1,2,3,4) and datatable2 has IDs(3,4).The new datatable should have the values (1,2)
I need all the rows from DataTable1 except DataTable2
How can I do this using LINQ? pls help
Posted
Updated 22-Feb-12 4:03am
v2

You don't need LINQ for this. It can be accomplished with RowFilter or Select on the DataTable
 
Share this answer
 
Comments
vivektp 22-Feb-12 9:53am    
How do I do this using Select on the DataTable?
You can join like this

C#
var q = from a in Table1
                           join b in Table2 on a.ID equals b.id
                           select new
                           {
                               a.id,
                               a.Number,
                               a.Name 
                           };
 
Share this answer
 
v2
Comments
vivektp 22-Feb-12 10:02am    
I need all the rows from DataTable1 except DataTable2

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