我试图找出我在下面的 LINQ 语句中做错了什么。它不喜欢第三个SELECT
。tblAddresse.tblAdminCounty
当我输入查询时 它会在 Intelisense 中找到,但是当我在它之后输入 SELECT 时它会发疯。
它与如何相关tblAddress
和tblAdminCounty
相关吗?我原以为它在 Intellisense 下显示的事实tblAddress
将使该声明不言自明,但显然不是。
如果我只是在单独的函数中查询 CountyName,它看起来像这样 -->
var countyName = from adminCounty in context.tblAdminCounties
where adminCounty.CountyID == countyID
select adminCounty.CountyName;
这是基于此站点的更大的 3 层方法 -->这里
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
}
}
};