Here's what I have
private readonly Dictionary<Type, List<object>> _cache;
public IList<T> Get<T> (Expression<Func<T, bool>> criteria)
{
return _cache[typeof(T)].Where (criteria);
}
The compiler complains (rightly) that it cannot convert from object to T.
How should I proceed from there?
Solution
return _cached[type].AsQueryable().Cast<T>().Where (criteria).ToList()
The idea is to have the List as an IQueryable and then I could Cast...