I have below linq sample:
List<FoodOrderItem> foodOrderItems = foodItemsWithPricesDbResult.ResultValue;
List<FoodOrderItem> orderItemsWithDiscounts= (from orderItem in order.Items
join foodOrderItem in foodOrderItems
on orderItem.FoodId equals foodOrderItem.Id
select mergeOrderAndFoodInformation(foodOrderItem,orderItem)).ToList();
.
.
.
private static FoodOrderItem mergeOrderAndFoodInformation(FoodOrderItem foodOrderItem, OrderItem orderItem)
{
foodOrderItem.DiscountValue = orderItem.DiscountValue;
foodOrderItem.DiscountKind = orderItem.DiscountKind;
foodOrderItem.CurrentOrderedCount = orderItem.Count;
return foodOrderItem;
}
This mergeOrderAndFoodInformation function updates some fields of input foodOrderItem object and return updated foodOrderItem.
1- How can I write the select mergeOrderAndFoodInformation(foodOrderItem,orderItem) part in inline style if I don't want to use a function such mergeOrderAndFoodInformation to update and return result? I mean how can I change the select mergeOrderAndFoodInformation(foodOrderItem,orderItem) segment if I want to write the code without using an external function?
2- How can I write this linq query using Lambda notation?
P.S. Accept my apologies if keyword such as inline and external are not used correctly. I would be thankful if you correct me in case there are some mistakes.