DataContext db = new DataContext(conString);
var dvd = db.GetTable<DvdList>();
var category = db.GetTable<CategoryList>();
var query= from b in dvd
join category on dvd.CategoryId equals category.CategoryId
where b.Title.Contains(txtSearch.Text)
select b;
GridView1.DataSource =query;
这里有错误“在DVD上加入类别”
答案 0 :(得分:3)
您尝试将category
用作范围变量名称和集合名称。试试这个:
var query= from b in dvd
join c in category on dvd.CategoryId equals c.CategoryId
where b.Title.Contains(txtSearch.Text)
select b;
(如评论中所述,加入实际上只是过滤掉类别ID不属于类别表的DVD ...在真实查询中,您实际上是否正在使用该类别?)