|
In a C# 2008 application, I have the following linq to sql statement setup so far.
eDataContext eData = new eDataContext();
var eSelect = (from iw in eData.Ibooks
join ip in etData.IPack on iw.P_ID equals ip.P_ID
join eTrack in eData.eRPT_Trans
on ip.TNum equals eTrack.P_ID
where ip.TNum == packageId
select iw).FirstOrDefault();
I want to obtain values from the 3 different tables listed in the statement above
How do I change the linq statement above so that I can obtain data from all three tables?
Thus can you show me how to obtain data from all 3 tables?
|
|
|
|
|
As part of your select statement, you can put any fields from the three tables in there, just as if you were doing a select in SQL. Ex: Select {iw, ip, eTrack}. The best thing would be to use select fields instead of all of the fields from all three tables.
|
|
|
|
|
eDataContext eData = new eDataContext();
var eSelect = (from iw in eData.Ibooks
join ip in etData.IPack on iw.P_ID equals ip.P_ID
join eTrack in eData.eRPT_Trans
on ip.TNum equals eTrack.P_ID
where ip.TNum == packageId
select new
{
iw.P_ID,
ip.P_ID,
eTrack.P_ID
/*
Other fields
*/
}
).FirstOrDefault();
|
|
|
|