from and select in c# .net? -
can please tell me how specify particular column in select statement given below:
var combinedrows = dt1 in dsresults.tables[0].asenumerable() join dt2 in dsresults.tables[1].asenumerable() on dt1.field<string>("methodname") equals dt2.field<string>("methodname") select new { dt1, dt2 }; datatable finaldt = new datatable("finaltable"); finaldt.columns.add(new datacolumn("sp", typeof(string))); finaldt.columns.add(new datacolumn("method", typeof(string))); finaldt.columns.add(new datacolumn("class", typeof(string))); finaldt.columns.add(new datacolumn("bllmethod", typeof(string))); datarow newrow = finaldt.newrow(); foreach (var row in combinedrows) { datarow datarow = finaldt.newrow(); datarow.itemarray = row.dt1.itemarray; finaldt.rows.add(datarow); }
if want specify columns want select, should try changing
combinedrows = dt1 in dsresults.tables[0].asenumerable() join dt2 in dsresults.tables[1].asenumerable() on dt1.field("methodname") equals dt2.field("methodname") select new { dt1, dt2 };
in
combinedrows = dt1 in dsresults.tables[0].asenumerable() join dt2 in dsresults.tables[1].asenumerable() on dt1.field("methodname") equals dt2.field("methodname") select new { dt1.columnname; dt2.columnname2; dt2.columnname3; etc. }
hope looking for.
you can have @ linq-cheatsheet
Comments
Post a Comment