So I've been advised a few times to disable lazy loading when building an application with the above frameworks, and that ToList() will force the queries in my repository to execute. I was told that I would avoid certain "traps" I might run into if I used AsEnumerable().
On a recent question, however, I included a bunch of ToList()s in my code examples, and startled a number of people that assured me IEnumerable is much better to return.
I'm thoroughly confused now, to say the least.
Should I be returning IEnumerable in my repository, then converting them to List in my view models? Should I use ToList() straightaway in my repository like I was before? Was I suppose to leave deferred execution enabled in the first place?
Jiminy Christmas...
Edit: So, being that I disabled lazy loading, based on earlier advice, should I then re-enable it, return IEnumerable / IQueryable from my repository, and convert the collection to a List in my view models, if needed?
One of the answers below associates IEnumerable with eager execution, while I was under the impression that only ToList() would force immediate execution of the query.
I stumbled across this, this, and this that all contain some interesting discussion related to this question.