You cannot, because you have already called ToList- this is not a Linq-to-Entities request, but just an instance List.
Try the following:
var CurrentStock = (from s in DBViews.StockStatus
where s.ProductID != 10
orderby s.ProductName
select new
{
s.ProductID,
s.ProductName,
CurrentStock = s.TotalStocked - s.TotalSold,
s.CurrentSellingRate,
CashValue = (s.TotalStocked - s.TotalSold) * s.CurrentSellingRate,
s.LastStocked,
s.LastCostPrice,
s.LastQtyStocked
});
File.AppendAllText(traceFile, ((ObjectQuery)CurrentStock).ToTraceString());
return CurrentStock.ToList();
Btw. why are you using dynamicinstead string? The dynamic type is intended only for special cases when it makes sense - it is not.
source
share