Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why IEnumerable
Message
De
09/11/2010 17:41:03
 
 
À
09/11/2010 15:07:16
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Versions des environnements
Environment:
C# 4.0
Divers
Thread ID:
01488625
Message ID:
01488662
Vues:
45
>>Hi,
>>Digging through some code I came to this code definition for the EF ObjectSet class:
public class ObjectSet<TEntity> : ObjectQuery<TEntity>, IObjectSet<TEntity>, IQueryable<TEntity>, IEnumerable<TEntity>, IQueryable, IEnumerable where TEntity : class {}
Since IQueryable implements IEnumerable I don't see why the latter is explicitly listed. Is it just superflous or am I missing some subtlety ?
>
>
>I haven't got vs2010 installed yet - so some thoughts
>
>
>(1) IEnumerable< >
>
>maybe because it implements that interface directly - have a look at the code
>
>(2) IQueryable< >
>
>I think - that IQueryable implements an interface that queries a 'datasource'. I suspect the IEnumerable of IQueryable will work on the result set that has been queried
>
>So, it you use IEnumerable on an ObjectSet, you'll be using the IEnumerable of the ObjectSet
>If you use the ObjectSet with LinQ using a where clause (or maybe things like .Take(n) ), you'll be using the IEnumerable of IQueryable

You lost me. Forget the generics. I'm just looking at the straight 'IQueryable' and 'IEnumerable' interfaces
AFAICS since the class is defined as implementing IQueryable it can, by extension, be cast to IEnumerable. So I'm looking for an example of usage that would not work if the IEnumerable implementation was not explicitly specified....
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform