开发者

How to join datatable using LINQ

开发者 https://www.devze.com 2023-02-03 21:36 出处:网络
I have two DataTables: dt1 - personid, name dt2 - personid I want to create a third datatable to include records from dt1 when they are NOT in dt2 using LINQ.In this case, I can bind the third data

I have two DataTables:

dt1 - personid, name

dt2 - personid

I want to create a third datatable to include records from dt1 when they are NOT in dt2 using LINQ. In this case, I can bind the third datatable to a dropdownlist.

any help would be great开发者_C百科! thanks!


Although it's in C#, But It could be translated to VB with a little effort

dt1.AsEnumerable()
   .Where(o => dt2.Select("personId =" + o["personId"].ToString()).Length == 0);

VB:

dt1.AsEnumerable()
   .Where(Function(o) 
      dt2.Select("personId =" & o("personId").ToString()).Length = 0)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号