我是lambda exp的新手。我创建了一个linq语句,但是我不知道如何将我的代码转换为lambda exp。
var result = (from order1 in Orders
join packedorder1 in VracExcluded 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,
Item = "0",
Ligne = packedorder1.codLine,
Material = packedorder1.codPackedProduct,
Produit = product1.codProductType,
MaterialDescription = packedproduct1.lblPackedProduct,
Lot = packedorder1.codPackedBatch,
RéférenceClient = product1.codCustomerColor,
Quantité = packedorder1.nbrPackedQuantity.ToString(),
Déjàimprimé = packedorder1.nbrLabelPrinted
}).ToList();
任何人都可以帮助我理解我如何创建linq查询的lambda exp?
答案 0 :(得分:0)
如果您不知道如何使用.net API,则使用msdn总是有用的。
var result = Orders.Join(VracExcluded, o => o.codOrder, v => v. codOrder, (o, v) => new { Order = o, VracExcluded = v })
.Join(Products, x => x.Order.codProduct, p => p.codProduct, (x, p) => new { Order = x.Order, VracExcluded = x.VracExcluded, Product = p })
.Join(PackedProducts, x => x.VracExcluded.codPackedProduct, pp => pp.codPackedProduct, (x, pp) => new { Order = x.Order, VracExcluded = x.VracExcluded, Product = x.Product, PackedProduct = pp })
.Where(x => x.Order.codOrder == _order.codOrder)
.Select(x => new FinishedProductPrintingM
{
OF = x.Order.codOrder,
Item = "0",
Ligne = x.VracExcluded.codLine,
Material = x.VracExcluded.codPackedProduct,
Produit = x.Product.codProductType,
MaterialDescription = x.PackedProduct.lblPackedProduct,
Lot = x.VracExcluded.codPackedBatch,
RéférenceClient = x.Product.codCustomerColor,
Quantité = x.VracExcluded.nbrPackedQuantity.ToString(),
Déjàimprimé = x.VracExcluded.nbrLabelPrinted
})
.ToList();