c# - convert a cached item to a specific object type for return by webmethod -
I have successfully cached a large data object in the web service, but if I run that cached item later Instead of wanting to revert long queries, how can I convert generic cached items to an object in my own design?
Like
HttpContext.Current.Cache.Insert ("cItem", [MIITEM])); then
returns HTTPPCTEx. Running Cache ["CITIM"]; The view will show an error in the studio because I can not change the type 'object' in its own way thanks to any pointer
and MyItem can be converted to a object , then reverse explicitly Is not true from. So if your method has a return type of myitm then you will need to insert the cached item: Public Maitrem () {} (MyEstm) HTTP Contex Current.catch ["ceist"]; } This is done while receiving it from the cache, not when it is stored in it.
If there is a possibility that the item is not of the expected type, you will in any case handle the situation, throw the above code a invalid cut exception If this happens, if you want to return only null to that condition, then you can try doing it instead: Public MyItem MyMethod () MyItem as {HttpContext.Current.Cache {"cItem"]; }
Comments
Post a Comment