Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have some errors in the code:</p> <ol> <li><p>You are putting the string 'item.Item1' instead of the value of property <code>Item1</code> of the variable <code>item</code>. Use <code>'@(item.Item1)'</code> instead.</p></li> <li><p>You are missing a comma at the end of each item in the <code>foreach</code> loop. The injected javascript is therefore invalid. You need </p> <p>&lt;text&gt;['@(item.Item1)', '@(item.Item2)'],&lt;/text&gt;</p></li> </ol> <p>EDIT: </p> <p>OK, so the problem is in the LINQ to entities query above.</p> <pre><code>IEnumerable&lt;Tuple&lt;DateTime,int&gt;&gt; points = _db.DepartmentNumbers.Where(x =&gt; x.Department.Id == 1).Select(x =&gt; new Tuple&lt;DateTime, int&gt;(x.Date, x.Number)); </code></pre> <p>The entity framework needs to be able to convert this query to a SQL query, and therefore does not accept the use of constructors with parameters within the query. The <code>Where</code> and <code>Select</code> clauses above are combined into one SQL query. </p> <p>A possible workaround is to first evaluate the part of the expression that needs to run on the database, get the data back to memory, and then create the tuples in memory. There are many overloads of the LINQ methods, some of these create expressions for LINQ to entities, some perform LINQ operations in memory. You need to make sure that the select which creates the tuple is executed in memory, i.e. you do not want the overload which applies to <code>IQueryable&lt;T&gt;</code>.</p> <pre><code>IEnumerable&lt;Tuple&lt;DateTime,int&gt;&gt; points = _db.DepartmentNumbers .Where(x =&gt; x.Department.Id == 1) // LINQ to Entities WHERE .Select(x =&gt; new { x.Date, x.Number }) // LINQ to Entities SELECT .AsEnumerable() // We want the next statement to be a select on IEnumerable instead of IQueryable. .Select(x =&gt; new Tuple&lt;DateTime, int&gt;(x.Date, x.Number)); // In-memory SELECT </code></pre>
    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.
    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