This code doesn’t work:
return this.Context.StockTakeFacts.Select(stf => ((stf.StockTakeId == stocktakeid) && (stf.FactKindId == ((int)kind)))).ToList<IStockTakeFact>();
This statement does:
var f = from stf in this.Context.StockTakeFacts
where (stf.StockTakeId == stocktakeid) && (stf.FactKindId == ((int)kind))
select stf;
return f.ToList<IStockTakeFact>();
What is the difference?? The first complains that IQueryable does not have a toList method so I gather I’ve written the first statement incorrectly.
You need to use a
Wherecall in order to filter elements (notSelect)When using explicit LINQ API queries the
select itemis implicit. It can be made explicit with a call toSelectbut it’s not necessary (unless you map the values in some way)