我有我认为是复杂的 SQL 查询,我需要将其转换为 LINQ 查询。但是,我只是 LINQ 的初学者,不知道如何让它工作。我试过搜索互联网,但仍然无法正常工作。
这是我的 SQL 查询:
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;
你好。这是我更新的 linq 查询,但它返回错误 Linq to Entities 无法识别方法 string.join。这有什么问题?谢谢。:)
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();