如何编写连接变量数据上下文?
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 类别”
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;
here has error "join category on dvd"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尝试使用
category
作为范围变量名称和集合名称。试试这个:(如评论中所述,连接实际上只是过滤掉类别 ID 不在类别表中的 DVD...在您的真实查询中,您实际上是否使用类别?)
You're trying to use
category
as both the range variable name and the collection name. Try this:(As noted in comments, the join is really just going to filter out DVDs whose category ID isn't in the category table... in your real query, are you actually using the category?)