lambda inner join and select all
12,397
If you want details of both tables, then you could have:
List<AllDetails> myObject = tableNames.Join(tableSchool, x => x.sID, s => s.schoolID, ((x, s) => new AllDetails(x, s))).ToList();
where:
public class AllDetails
{
private TableName tabName;
private TableSchool tabSchool;
public AllDetails(TableName tableName, TableSchool tableSchool)
{
//Assign fields here
}
}
Comments
-
zey almost 2 years
Here is how I
inner join
in lambda ,var myObject = tableNames.Join(tableSchool, x => x.sID , s => s.schoolID , ( (x,s) => new { } ) ).ToList();
I have many fields in both
tableNames
andtableSchool
.
By my lambda query , if I have 10 fields intableNames
, I've to write down all of 10 fields innew { }
10 times.
What I want to know is how can I select all fields oftableName
table and one field fromtableSchool
.Example
tableName tableSchool --------- ------------ Nfield1 Sfield1 Nfield2 Sfield2 Nfield3 Sfield3 Nfield4 Nfield5
I want to get all fields from
tableName
and just one field (Sfield1) fromtableShcool
. I want to bind this datasource to asp:GridView :) -
zey almost 11 yearsI want to bind this to
asp.net GridView
datasource .