c# - How to combine and retrieve multiple columns from two tables in a Dataset -
c# - How to combine and retrieve multiple columns from two tables in a Dataset -
i have dataset 2 tables connected reference (loop_id)
table1 column1 column2 loop_id 1 itemcode_aaa 6 2 itemcode_bbb 8 table2 column1 loop_id 2014-sep-09 6 2014-nov-09 8
how retrieve columns, except loop_id both tables single table. resulting table should appear like
t1_column1 t1_column2 t2_column1 1 itemcode_aaa 2014-sep-09 2 itemcode_bbb 2014-nov-09
i using net framework 4.5
use linq datasets:
to enumerate table, phone call asenumerable
.
datatable table1 = ds.tables["table1"]; datatable table2 = ds.tables["table2"]; var records = (from t1 in table1.asenumerable() bring together t2 in table2.asenumerable() on t1.field<int>("loop_id") equals t2.field<int>("loop_id") select new {t1_column1 = t1.field<string>("column1"), t2_column2 = t2.field<string>("column2"), t2_column1 = t2.field<string>("column1")});
c# .net dataset .net-4.5 dataview
Comments
Post a Comment