How is VAR determined in many ways?

I have this code:

IEnumerable<string> q = customers /*EF entity*/ .Select (c => c.Name.ToUpper()) .OrderBy (n => n) 

To select an object, an ObjectContext actually creates an ObjectQuery that implements IQueryable. The object returned from ObjectQuery is not a normal object, but an EntityObject

but what if I write: (pay attention to var )

 var q = customers /*EF entity*/ .Select (c => c.Name.ToUpper()) .OrderBy (n => n) 

it can be defined as ienumerable or iqueryable :

because ObjectQuery also implements ienumerable ...

I don’t know if there is any specific information that tells the compiler to "use A, not B. A is more specific ..." (should be ... I just can't find it)

enter image description here

any help? how will he know to use A || B

+4
source share
1 answer

IQueryable<T> itself inherits from IEnumerable<T> , so it is more specific than IEnumerable<T> , although ObjectQuery<T> implements both common interfaces.

+4
source

All Articles