title: How to call a stored procedure that returns a list<int> using .net core entity framework
body: <p>I am migrating a <code>.Net Framework</code> project to <code>.Net Core</code>. In my <code>.Net Framework</code> code I call a stored procedure and it returns a <code>list&lt;int&gt;</code> in a <code>datatable</code>:</p>
  <pre><code> DataTable dt = new DLDistinctWarehousePackingOperation().CreatePacking(packingId, userId, 
   previousOrderId, totalAwaitingOrdersAllowed);
          List&lt;int&gt; items = new List&lt;int&gt;();
          foreach (DataRow dr in dt.Rows)
          {
              items.Add(int.Parse(dr[&quot;orderid&quot;].ToString()));
          }
          return items;
  </code></pre>
  <p>This is the <code>.Net Core</code> code I have come up with until now:</p>
  <pre><code>List&lt;int&gt; items = dbContext.FromSql(&quot;CreatePacking&quot;)
              .Select(t =&gt; new List&lt;int&gt; { t.OrderId.Value })
              .ToList();
  </code></pre>
  <p>But it doesn't work. The problem is that an object needs to follow dbContext  - like this dbContext.MyObject.FromSql - but in this case it should just be a List of ints - the stored procedure is not connected to any specific object. And how can I return a <code>List&lt;int&gt;</code>? or perhaps it has to be converted into a class? Thanks in advance.
  <a href="https://i.stack.imgur.com/LqjNm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LqjNm.png" alt="enter image description here" /></a></p>