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.
Here is my SQL query:
SELECT
a.empid,
CAST(IF(COUNT(*) > 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;
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. :)
var rows = from rec in context.tblWMSLogs join rec1
in context.tblWMSLogs.Where(t => t.DateAdded == refDate2 && t.IsDeleted == 0)
on rec.EmpID equals rec1.EmpID
where rec.DateAdded == refDate2 && rec.IsDeleted == 0 && !rec.Remarks.Contains("proxy date used") && rec.RecType == recType
group rec by rec.EmpID into g
select new WMSRandomViewModel
{
EmpID = g.Key,
Lim = (g.Count() > 10 ? Math.Ceiling(g.Count() / 10d) : 1),
InternalIDs = string.Join(",", g.OrderBy(s => s.InternalID).Select(s => s.InternalID))
};//string.Join(",", g.OrderBy(s => s.InternalID).Select(s => s.InternalID))
//return rows.ToList();
return rows.ToList();