M
muchotako
Guest
I have this code:
private Dictionary<Type, List<ICacheable>> cachedEntities;
public ICacheable GetFromCache<T>(Expression<Func<T, bool>> predicate) where T : ICacheable
{
var type = typeof(T);
if (!cachedEntities.ContainsKey(type))
cachedEntities.Add(type, new List<T>());
var entitiesList = cachedEntities[type].AsQueryable();
var result = entitiesList.Where(predicate);
return result;
}
I'm getting an error when trying to add the new List<T> to the dictionary claiming that it can't convert from T to ICacheable, but I force T to implement, so I'm not really understanding why I'm getting it.
I'm also getting an error in the entitiesList.Where(predicate) claiming it can't convert from Expression<Func<T,bool>> to Expression<Func<ICacheable, int, bool>>.
Continue reading...
private Dictionary<Type, List<ICacheable>> cachedEntities;
public ICacheable GetFromCache<T>(Expression<Func<T, bool>> predicate) where T : ICacheable
{
var type = typeof(T);
if (!cachedEntities.ContainsKey(type))
cachedEntities.Add(type, new List<T>());
var entitiesList = cachedEntities[type].AsQueryable();
var result = entitiesList.Where(predicate);
return result;
}
I'm getting an error when trying to add the new List<T> to the dictionary claiming that it can't convert from T to ICacheable, but I force T to implement, so I'm not really understanding why I'm getting it.
I'm also getting an error in the entitiesList.Where(predicate) claiming it can't convert from Expression<Func<T,bool>> to Expression<Func<ICacheable, int, bool>>.
Continue reading...