我有一个使用UNION的Transact SQL查询,需要一些指针,了解如何在LINQ中实现,比如一些示例会很好,或者如果有人可以推荐一个关于LINQ中UNIONS的好教程。
select top 10 Barcode, sum(ItemDiscountUnion.AmountTaken) from
(SELECT d.Barcode,SUM(AmountTaken) AmountTaken
FROM [Aggregation].[dbo].[DiscountPromotion] d
GROUP BY d.Barcode
UNION ALL
SELECT i.Barcode,SUM(AmountTaken) AmountTaken
FROM [Aggregation].[dbo].ItemSaleTransaction i
group by i.Barcode) ItemDiscountUnion
group by Barcode
请注意,原始 SQL 是将 2 个选择 合并 而不是连接它们。我需要知道如何合并结果,即去除重复项并对重复基于条形码的行金额进行求和。