I get the following error:
Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Data.Entity.DbSet'.
An explicit conversion exists (are you missing a cast?)
I have the following code:
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.
I think you need
List<ProdVal> reports;
if (searchField == "StoreNum")
{
int storeNum;
int? stnum = int.TryParse(searchString, out storeNum) ? storeNum : (int?)null;
reports = (dbContext.Product
.Where(w => w.StoreNum == stnum)).ToList(); // error occurs here when I try to build
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With