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
.
Compare two tables by using joins. To compare two tables by using joins, you create a select query that includes both tables. If there is not already an existing relationship between the tables on the fields that contain the corresponding data, you create a join on the fields that you want to examine for matches.
To join two data frames (datasets) vertically, use the rbind function. The two data frames must have the same variables, but they do not have to be in the same order. If data frameA has variables that data frameB does not, then either: Delete the extra variables in data frameA or.
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"));
i think this code will help u to do it without using entity...
Dt1.Merge(Dt2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With