开发者

How to join datatable using LINQ

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜