Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Convert SQL query to LINQ
    primarykey
    data
    text
    <p>I have what I think is a complex SQL query, and i need to convert it to LINQ query. But, I'm only a beginner in LINQ and don't know how to get this working. I've tried searching the internet and still unable to get it to work.</p> <p>Here is my SQL query:</p> <pre><code>SELECT a.empid, CAST(IF(COUNT(*) &gt; 10,FLOOR(COUNT(*) / 10),1) AS CHAR(100)) lim, CAST(GROUP_CONCAT(internalid) AS CHAR) internalIDS FROM tblLogs a INNER JOIN ( SELECT DISTINCT empid FROM tblLogs WHERE IsDeleted = 0 AND DateAdded = 2013-04-18 ) b ON a.empid = b.empid WHERE IsDeleted = 0 AND Remarks NOT LIKE '%proxy date used%' AND DateAdded = 2013-04-18 AND RecType = 8 GROUP BY empid; </code></pre> <p>Hi. Here is my updated linq query, but it returns an error Linq to Entities does not recognize the method string.join. What's wrong with this? Thanks. :)</p> <pre><code>var rows = from rec in context.tblWMSLogs join rec1 in context.tblWMSLogs.Where(t =&gt; t.DateAdded == refDate2 &amp;&amp; t.IsDeleted == 0) on rec.EmpID equals rec1.EmpID where rec.DateAdded == refDate2 &amp;&amp; rec.IsDeleted == 0 &amp;&amp; !rec.Remarks.Contains("proxy date used") &amp;&amp; rec.RecType == recType group rec by rec.EmpID into g select new WMSRandomViewModel { EmpID = g.Key, Lim = (g.Count() &gt; 10 ? Math.Ceiling(g.Count() / 10d) : 1), InternalIDs = string.Join(",", g.OrderBy(s =&gt; s.InternalID).Select(s =&gt; s.InternalID)) };//string.Join(",", g.OrderBy(s =&gt; s.InternalID).Select(s =&gt; s.InternalID)) //return rows.ToList(); return rows.ToList(); </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