当我尝试以下 SQL 查询时,我得到了我想要的结果:
SELECT City FROM Hotel GROUP BY City
但以下实体框架查询不返回任何结果:
string CityKey = CityDropDownList.SelectedValue;
MedicalEntities entity = new MedicalEntities();
CityDropDownList.DataSource = (from p in entity.Hotels
where p.City == CityKey
group p by p.City into g
select new
{
City = g.Key
}).ToList();
我已经尝试了该查询的许多变体,但没有成功。我想,它非常简单,不需要额外的信息。任何帮助,将不胜感激