DataClassesDataContext MyDB = new DataClassesDataContext();
var id = from wineT in MyDB.Wineries
where wineT.wineryID==Convert.ToInt32(
from w in MyDB.WineTypes
where w.kind==ddlSorti.SelectedItem.Text
select w.wineryID)
select wineT.name;
GridView1.DataSource = id;
GridView1.DataBind();
我有这个代码,我没有任何错误,但是当我启动应用程序时,我收到此错误“无法格式化节点'ClientQuery'以执行为SQL”。
答案 0 :(得分:2)
您需要在子选择中添加FirstOrDefault()
var id = from wineT in MyDB.Wineries
where wineT.wineryID==Convert.ToInt32(
from w in MyDB.WineTypes
where w.kind==ddlSorti.SelectedItem.Text
select w.wineryID).FirstOrDefault()
select wineT.name;