下面的查询可以用LINQ to SQL实现吗?
select id,
(select StateName from b_mstates where id=StateIdFk) as [State Name],
CityName
from b_mcities
var result = b_mcities.where(x => b_mstates.where(y => y.id == StateIdFK)
.contains(x.statename)).ToList();
你的问题是相当困难的,因为你的sql不会运行(它是畸形和缺少逻辑)。
假设您已经正确设置了关联,它应该像
一样简单var result = from city in m_bcities
select new {city.id, city.State.StateName, city.CityName}