may help you . Your first select is querying the database and returns IQueryable. .AsEnumerable() make it IEnumerable. IQueryable extends IEnumerable so whatever you can do with IEnumerable, you can also do with IQueryable You often use .AsEnumerable() to materialize your query so other non sql statements can be performed on the result set as per this example
var data = (from temp in context.UserDetails select temp)
.Select(d => new UserDetailsModel
Fullname = d.fullName,
Email = d.Email
}).ToList()); // or AsEnumerable()
will help you You understanding is correct. After calling AsEnumerable the data source can no longer be queried and it falls back to a simplistic "give me everything" mode, which means all the data is transferred to the client and any further operations are done locally. That's also the reason why the query doesn't work as written: in order for it to work, all the expressions you use in LINQ methods must be translatable to whatever language is understood by your data source -- and since it is the query provider's responsibility to do the translation, you will also be constrained by whatever it is programmed to support.
it fixes the issue The difference between AsEnumerable and AsQueryable is that the enumerable contains all information to create an enumerator. Once you've got the enumerator you can ask for the first element, and if there is one, you can get the next one. The Queryable does not hold the information to create the enumerator. It holds an Expression and a Provider. The Provider knows which process must execute the Expression and which language this process uses. Quite often the other process is a database management system, and the language is SQL.
Does first iteration over .AsEnumerable execute the entire query?