Error: "cannot Implicitly Convert Type"
I am working on one project and I have a question regarding the converting type. I want to create simple search for my project, but it keeps asking about Ienumerable type, which ho
Solution 1:
While products
is indeed of type IPagedList<Product_List>
, the call to .Where()
on an instance of IPagedList<Product_List>
returns an IEnumerable<Product_List>
, which can't be implicitly converted. Notice how you perform conversions here:
products = _db.Product_list.OrderByDescending(m => m.ID)
.ToPagedList(pageIndex, pageSize);
You just need to perform the same conversion after your .Where()
call:
products = products.Where(m => m.ID.ToUpper().Contains(searchString.ToUpper()) ||
m.Product_name.ToUpper().Contains(searchString.ToUpper()))
.ToPagedList(pageIndex, pageSize);
Post a Comment for "Error: "cannot Implicitly Convert Type""