我有以下SQL查询,我必须使用LINQ构建它,但是找到一个简单的方法太复杂了。 : - /
首先是查询:
SELECT * FROM tbl_a
LEFT JOIN
(
SELECT tbl_a.id AS id
SUM(tbl_b.amount) AS amount
FROM (tbl_a LEFT JOIN tbl_c ON tbl_a.id = tbl_c.from_this_id)
LEFT JOIN tbl_b ON tbl_c.id = tbl_b.tbl_c_id
WHERE (tbl_c.deleted = FALSE)
AND tbl_b.deleted = FALSE
AND tbl_b.status = 2
GROUP BY tbl_a.id
) tbl_tmp
ON tbl_a.id = tbl_tmp.id
WHERE (tbl_tmp.amount Is NULL OR tbl_a.amount > tbl_tmp.amount)
AND tbl_a.amount > 0
AND tbl_a.item_ID = item.Id
AND tbl_a.type_ID = type.Id
AND tbl_a.deleted = FALSE
我必须告诉你,“item.Id”和“type.Id”是long类型的参数,所以你可以用数字替换它们。
有人可以帮我制作一个具有相同结果的替代查询,所以我可以将它与LINQ一起使用吗?或者有人可以直接将其转换为LINQ?!