Do you really need to return IQueryable ? Returning IQueryable from your method does not provide much functionality, since you cannot access elements of an anonymous type without reflection. In this case, I suggest you create a specific query type to be able to return an IQueryable<T> :
class TaxIncrease { public int Tax { get; set; } public int Increase { get; set; } } public IQueryable<TaxIncrease> listAll() { ModelQMDataContext db = new ModelQMDataContext(); return from t in db.tax select new TaxIncrease {Tax = t.tax1, Increase = t.increase}; }
and then you can:
listAll().Count();
source share