How to union two data tables and order the result

匿名 (未验证) 提交于 2019-12-03 00:46:02

问题:

Q: If I have two DataTables like this :

Dt1(emp_num,emp_name,type)

Dt2(emp_num,emp_name,type)

I wanna to Union them and order the result by emp_name.

回答1:

var dt1 = new DataTable(); // Replace with Dt1 var dt2 = new DataTable(); // Replace with Dt2  var result = dt1.AsEnumerable()             .Union(dt2.AsEnumerable())             .OrderBy (d => d.Field<string>("emp_name")); 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!