{"action":"created","issue":{"url":"https://api.github.com/repos/MichaCo/CacheManager/issues/62","repository_url":"https://api.github.com/repos/MichaCo/CacheManager","labels_url":"https://api.github.com/repos/MichaCo/CacheManager/issues/62/labels{/name}","comments_url":"https://api.github.com/repos/MichaCo/CacheManager/issues/62/comments","events_url":"https://api.github.com/repos/MichaCo/CacheManager/issues/62/events","html_url":"https://github.com/MichaCo/CacheManager/issues/62","id":158557619,"number":62,"title":"InvalidCastException: Object must implement IConvertible when using Get method with interface as type","user":{"login":"alexanderar","id":1175517,"avatar_url":"https://avatars.githubusercontent.com/u/1175517?v=3","gravatar_id":"","url":"https://api.github.com/users/alexanderar","html_url":"https://github.com/alexanderar","followers_url":"https://api.github.com/users/alexanderar/followers","following_url":"https://api.github.com/users/alexanderar/following{/other_user}","gists_url":"https://api.github.com/users/alexanderar/gists{/gist_id}","starred_url":"https://api.github.com/users/alexanderar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexanderar/subscriptions","organizations_url":"https://api.github.com/users/alexanderar/orgs","repos_url":"https://api.github.com/users/alexanderar/repos","events_url":"https://api.github.com/users/alexanderar/events{/privacy}","received_events_url":"https://api.github.com/users/alexanderar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/MichaCo/CacheManager/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-05T14:43:15Z","updated_at":"2016-06-05T15:08:35Z","closed_at":null,"body":"I have a pretty simple scenario:\r\n\r\n1. Repo class that returns a `IList<SomeDto>` items\r\n```\r\npublic class Repo\r\n{\r\n      public IList<SomeDto> Get()\r\n      {\r\n           return new List<SomeDto>();\r\n      }\r\n}\r\n```\r\n2. service class that has a ICacheManager<object> and uses it to cache the repo result:\r\n\r\n```\r\npublic class Service\r\n{\r\n      private ICacheManager<object> _cacheManager;\r\n\r\n      private Repo _repo;\r\n      \r\n      public Service(ICacheManager<object> cacheManager, Repo repo)\r\n      {\r\n            this._cacheManager = cacheManager;\r\n            this._repo = repo;\r\n      }\r\n\r\n      public  IList<SomeDto> Get()\r\n      {\r\n             var items =  this._cacheManager.Get< IList<SomeDto>>(\"items\");\r\n             if(items == null)\r\n             {\r\n                   items = this._repo.Get();\r\n                   this._cacheManager.Add(\"items\",items);\r\n              }\r\n              return items;\r\n      }\r\n}\r\n```\r\n\r\nAfter cache has been instantiated with items\r\n `this._cacheManager.Get< IList<SomeDto>>(\"items\")` throws an `InvalidCastException: Object must implement IConvertible`, while if I change it to \r\n`this._cacheManager.Get<List<SomeDto>>(\"items\")` -- notice `List` instead of `IList` -- the cache works as expected.\r\n\r\nMy question is whether it is possible to use interfaces/base classes to retrieve items from cache.\r\n\r\nThanks in addvance\r\n\r\nAlex"},"comment":{"url":"https://api.github.com/repos/MichaCo/CacheManager/issues/comments/223818309","html_url":"https://github.com/MichaCo/CacheManager/issues/62#issuecomment-223818309","issue_url":"https://api.github.com/repos/MichaCo/CacheManager/issues/62","id":223818309,"user":{"login":"MichaCo","id":5837539,"avatar_url":"https://avatars.githubusercontent.com/u/5837539?v=3","gravatar_id":"","url":"https://api.github.com/users/MichaCo","html_url":"https://github.com/MichaCo","followers_url":"https://api.github.com/users/MichaCo/followers","following_url":"https://api.github.com/users/MichaCo/following{/other_user}","gists_url":"https://api.github.com/users/MichaCo/gists{/gist_id}","starred_url":"https://api.github.com/users/MichaCo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MichaCo/subscriptions","organizations_url":"https://api.github.com/users/MichaCo/orgs","repos_url":"https://api.github.com/users/MichaCo/repos","events_url":"https://api.github.com/users/MichaCo/events{/privacy}","received_events_url":"https://api.github.com/users/MichaCo/received_events","type":"User","site_admin":false},"created_at":"2016-06-05T15:08:35Z","updated_at":"2016-06-05T15:08:35Z","body":"yup can be changed so that the converting Get<T> method supports that"}}
{"actor":{"display_login":"MichaCo"}}