Note that there are some explanatory texts on larger screens.

plurals
  1. POTime to start returning IQueryable<T> instead of IList<T> to my Web UI / Web API Layer?
    primarykey
    data
    text
    <p>I've got a multi-layer application that starts with the repository pattern for all data access and it returns IQueryable to the Services layer. The Services layer, which includes all of the business logic, returns IList to the Controllers (note: I'm using ASP.NET MVC for the UI layer). The benefit of returning IQueryable in the data access layer is that it allows my repositories to be extremely simple and the database queries to be deferred. However, I'm triggering the database queries in my services layer so that my unit tests is more reliable and I don't give flexibility to the Controllers to reshape my queries. However, I've recently encountered several situations where deferring the execution of queries down to the Controllers would have been significantly more performant because the Controllers had to do some projections on the data that was UI specific. Additionally, with the emergence of things like oData, I was starting to wonder if end points (e.g. web UI or web apis) should be working directly with IQueryable. What are your thoughts? Is it time to start returning IQueryable from the services layer to the UI layer? Or stick with IList?</p> <p>This thread here: <a href="https://stackoverflow.com/questions/718624/to-return-iqueryablet-or-not-return-iqueryablet">To return IQueryable&lt;T&gt; or not return IQueryable&lt;T&gt;</a> seems to vouch for returning IList to the UI layers, but I was wondering if things are changing because of new emerging technologies and techniques.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload