Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I use CompiledQuery
    primarykey
    data
    text
    <p>I used the linq to fetch the data from database before, but it looks like using CompiledQuery with Linq should be than using Linq by itself.</p> <p>I've try to use CompiledQuery, but it's throwing an exception.</p> <p>Following is my code:</p> <pre><code>static readonly Func&lt;myEntity, int?, List&lt;myDataModel&gt;&gt; s_compiledQuery2 = CompiledQuery.Compile&lt;myEntity, int?, List&lt;myDataModel&gt;&gt; ( (ctx, NULLUserId) =&gt; ( from jlr in ctx.C_InternetCafe where jlr.USER_ID != NULLUserId select new myDataModel { pid = jlr.PC_ID ?? 0, uid= jlr.USER_ID ?? 0 } ).ToList() ); static List&lt;myDataModel&gt; CompiledQuery2() { using (myEntity context = new myEntity()) { int? UserId = null; List&lt;myDataModel&gt; orders = s_compiledQuery2.Invoke(context, UserId); return orders; } } public List&lt;myDataModel&gt; getCustomerInf() { return CompiledQuery2(); } </code></pre> <p>I just want to fetch the values "PC_ID" and "USER_ID" from table <code>C_InternetCafe</code>, and add them to myDataModel whose datamember has <code>pid</code> and <code>uid</code>.</p> <p>//----------------------------------------------------------------------------</p> <p>Forgive my negligence, the following are the exception I got.</p> <pre><code>NotSupportedException { "LINQ to Entities does not recognize the method 'System.Collections.Generic.List`1 [InternetCafeManager.Web.DataModel.myDataModel] ToList[myDataModel] (System.Collections.Generic.IEnumerable`1 [InternetCafeManager.Web.DataModel.myDataModel])' method, and this method cannot be translated into a store expression" } </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.
 

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