You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class Repo
{
public IList<SomeDto> Get()
{
return new List<SomeDto>();
}
}
service class that has a ICacheManager and uses it to cache the repo result:
public class Service
{
private ICacheManager<object> _cacheManager;
private Repo _repo;
public Service(ICacheManager<object> cacheManager, Repo repo)
{
this._cacheManager = cacheManager;
this._repo = repo;
}
public IList<SomeDto> Get()
{
var items = this._cacheManager.Get< IList<SomeDto>>("items");
if(items == null)
{
items = this._repo.Get();
this._cacheManager.Add("items",items);
}
return items;
}
}
After cache has been instantiated with items this._cacheManager.Get< IList<SomeDto>>("items") throws an InvalidCastException: Object must implement IConvertible, while if I change it to this._cacheManager.Get<List<SomeDto>>("items") -- notice List instead of IList -- the cache works as expected.
My question is whether it is possible to use interfaces/base classes to retrieve items from cache.
Thanks in addvance
Alex
The text was updated successfully, but these errors were encountered:
I have a pretty simple scenario:
IList<SomeDto>
itemsAfter cache has been instantiated with items
this._cacheManager.Get< IList<SomeDto>>("items")
throws anInvalidCastException: Object must implement IConvertible
, while if I change it tothis._cacheManager.Get<List<SomeDto>>("items")
-- noticeList
instead ofIList
-- the cache works as expected.My question is whether it is possible to use interfaces/base classes to retrieve items from cache.
Thanks in addvance
Alex
The text was updated successfully, but these errors were encountered: