我如何避免额外循环并在 LINQ 任务本身中构造顺序。
GetOrderListDataContext orderListDaCtx = new GetOrderListDataContext(address);
// This line showing compiler error could not find implementation of query pattern for source type int Select not found
var orderList = from order in orderListDaCtx.Base_Purchase_GetOrderListByUser_WS(request.UserGuid, request.CountryCode, request.FromDate, request.ToDate)
select order;
// Here how i can avoid this loop and construct order object in the LINQ itself above
List<Order> orders = new List<Order>();
foreach (var order in orderList)
{
orders.Add(new Order
{
OrderKey = order.OrderKey,
UserEmail = order.UserEmail,
CreatedDate = order.CreatedDate
});
}
return orders;