在C#LINQ中实现Concat + RANK OVER SQL子句

时间:2018-07-17 06:50:40

标签: entity-framework linq mvvm

我需要实现以下T-SQL子句....

SELECT      
    CONCAT( RANK() OVER (ORDER BY [Order].codOrder, [PackedOrder].codPackedProduct ),  '/2') as Item,
        [Order].codOrder as [OF],   

        [PackedOrder].codLine as [Ligne], 
        [PackedOrder].codPackedProduct as [Material],  ---------------------- 
        [Product].lblPProduct as [Product], 
        [PackedProduct].lblPackedProduct as [MaterialDescription], 
        [PackedOrder].codPackedBatch as [Lot], 
        [Product].codCustomerColor as [ReferenceClient], 
        [PackedOrder].nbrPackedQuantity as [Quantity], 
        [PackedOrder].nbrLabelToPrint as [DejaImprime]  
    FROM [Order] INNER JOIN PackedOrder  

ON [Order].codOrder = PackedOrder.codOrder INNER JOIN Product 
        ON [Order].codProduct = Product.codProduct INNER JOIN PackedProduct 
        ON PackedOrder.codPackedProduct = PackedProduct.codPackedProduct        
    Where [Order].codOrder = 708243075     


So Far, I'm able to do:  


                var result =
                            from order1 in Orders
                            join packedorder1 in PackedOrders on order1.codOrder equals packedorder1.codOrder
                            join product1 in Products on order1.codProduct equals product1.codProduct
                            join packedproduct1 in PackedProducts on packedorder1.codPackedProduct equals packedproduct1.codPackedProduct
                            where order1.codOrder == _order.codOrder

                            select new FinishedProductPrintingM
                            {
                                OF = order1.codOrder,                                
                                Ligne = packedorder1.codLine,
                                Material = packedorder1.codPackedProduct,
                                Produit = product1.codProductType,
                                MaterialDescription = packedproduct1.lblPackedProduct,
                                Lot = packedorder1.codPackedBatch,
                                RéférenceClient = product1.codCustomerColor,
                                Quantité = packedorder1.nbrPackedQuantity,
                                Déjàimprimé = packedorder1.nbrLabelPrinted
                            };

请告诉我是否可能。我需要以这种方式显示商品。请随时添加您的宝贵意见。

我不知道如何在LINQ中使用concat和Rank over函数。

有人可以帮助我将SQL查询转换为LINQ吗?

0 个答案:

没有答案