I am trying to figure out what I am doing wrong in the below LINQ statement. It doesn't like the third SELECT
. It finds tblAddresse.tblAdminCounty
in Intelisense when I am typing the query but when I type the SELECT after it it freaks.
Does it have to do with how tblAddress
and tblAdminCounty
are related? I would have thought that the fact it shows in Intellisense under tblAddress
would make that statement self-evident but obviously not.
If I was to query just the CountyName in a seperate function it would look like this -->
var countyName = from adminCounty in context.tblAdminCounties
where adminCounty.CountyID == countyID
select adminCounty.CountyName;
And this is the larger 3-tiered approach based on this site --> HERE
var query = from tblBusinesse in context.tblBusinesses
where tblBusinesse.BusinessID == businessID
select new
{
tblBusinesse.BusinessName,
tblBusinesse.ContactName,
tblBusinesse.EmailAddress,
Address = from tblAddresse in tblBusinesse.tblAddresses
select new
{
tblAddresse.AddressLine1,
tblAddresse.AddressLine2,
tblAddresse.AddressLine3,
tblAddresse.CityName,
County = from adminCounty in tblAddresse.tblAdminCounty
select new
{
adminCounty.CountyName
}
}
};