Working with the interface, we are usually a var or iQueryable which is going to return a set of data objects , Then we put it on the interface and return to the list or as an iList, such as:
var item = in some tee where the condition is true ==; Return items Toolist (.) Cost and Lieutenant; Some interface & gt; () .toList (); Note: items.Cast () .toList () will compile, but will throw an invalidcache exception at runtime.
Is there any better way? (I've put ToList / Cast / ToList in an extension method, but it's not really any better ...)
returns items. Catastolite & lt; SomeClass, SomeInterface & gt; (); Thanks!
what you are doing is right (you can cast directly IQueryable , but this sub optimal, because you actually only need one when you are creating 2 lists instead of toList Use asenumerable :
Return items. ANNMereable (). Cast & lt; SomeInterface & gt; (). ToList (); Validate Cast due to IEnumerable because of calling asenumerable Or, not IQueryable , the artist will be on the actual object directly instead of DB DB.
Comments
Post a Comment