from and select in c# .net?

前端 未结 5 1111
后悔当初
后悔当初 2021-01-29 10:02

Can anyone Please tell me how to specify the particular column in the select statement given below:

var combinedrows = from dt1 in DsResults.Tables[0].AsEnumerab         


        
5条回答
  •  萌比男神i
    2021-01-29 10:55

    If you want to specify which columns you want to select, you should try changing

    combinedrows = from 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 = from 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 this what you were looking for.

    You can have a look at the LinQ-CheatSheet

提交回复
热议问题