本文介绍了无法将类型'System.Linq.IQueryable隐式转换为System.Data.Entity.DbSet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到以下错误:
我有以下代码:
var reports = dbContext.Product;
if (searchField == "StoreNum")
{
int storeNum;
int? stnum = int.TryParse(searchString, out storeNum) ? storeNum : (int?)null;
reports = dbContext.Product
.Where(w => w.StoreNum == stnum); // error occurs here when I try to build
}
我不明白为什么收到此消息.
I cannot understand why I am getting this message.
推荐答案
var reports = dbContext.Product.ToList();
if (searchField == "StoreNum")
{
int storeNum;
int? stnum = int.TryParse(searchString, out storeNum) ? storeNum : (int?)null;
reports = reports
.Where(w => w.StoreNum == stnum).AsQueryable(); // error occurs here when I try to build
}
这篇关于无法将类型'System.Linq.IQueryable隐式转换为System.Data.Entity.DbSet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!