Cannot convert type 'bool' to 'System.Linq.IQueryable<My.Models.MyDataList>'
public IQueryable<MyDataList> GetMyDataList(int id)
{
var result = db.MyDataLists.All(b => b.MyDa开发者_JAVA百科taListID== id);
return (IQueryable<MyDataList>)result ;
}
The All
method returns a boolean indicating whether all of the items match a condition.
You're trying to call Where
, not All
.
What you want is Where()
not All()
. All()
is like "Do all items in the list satisfy this condition or not?" not "get all items that satisfy condition".
All returns a bool indicating if all items in the list match the predicate. You're then trying to cast bool to IQueryable<MyDataList>
public IQueryable<MyDataList> GetMyDataList(int id)
{
return db.MyDataLists.Where(b => b.MyDataListID== id);
}
Thats probably what you wanna do.
精彩评论