Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>IQueryable</code> is used when you are using Linq-to-entities = you are building declarative LINQ query in your application which will be interpreted by LINQ provider as SQL and executed on the server. Once the query is executed (iterated) it will turn to become IEnumerable and objects will be materialized as needed for iteration = not immediately.</p> <p>Once you call stored procedure you are not using Linq-to-entities because there is no declarative query built in your application. The query / SQL already exists on database server and you are just invoking it. This will return <code>IEnumerable</code> but again it will not materialize all results immediately. Results will be materialized as iterated. This is principle of database cursor / or .NET data reader when you explicitly ask for fetching object.</p> <p>So if you call something like this:</p> <pre><code>foreach (var keyword in dbContext.FindCoursesWithKeywords(keywords) .Select(l =&gt; l.Value)) { ... } </code></pre> <p>You are fetching courses one by one (btw. why to load whole course if you are interested only in keywords?). Until you complete or break the loop your data reader is opened to fetch records.</p> <p>If you instead call this:</p> <pre><code>foreach (var keyword in dbContext.FindCoursesWithKeywords(keywords) .ToList() // or ToArray .Select(l =&gt; l.Value)) { ... } </code></pre> <p>You will force query to materialize all results immediately and loop will perform on collection in memory instead of opened database reader.</p> <p>Difference between <code>IEnumerable</code> and <code>IQueryable</code> is not in the way how data are fetched because <code>IQueryable</code> is <code>IEnumerable</code>. The difference is in backing construct (something must implement these interfaces). </p>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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