gpt4 book ai didi

c# - 避免额外的循环并且找不到源类型 int 的查询模式的实现 Select not found

转载 作者:太空狗 更新时间:2023-10-30 01:06:34 25 4
gpt4 key购买 nike

如何在 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;

最佳答案

你是这个意思吗?

GetOrderListDataContext orderListDaCtx = new GetOrderListDataContext(address);
var orderList = from order in orderListDaCtx.Base_Purchase_GetOrderListByUser_WS(request.UserGuid, request.CountryCode, request.FromDate, request.ToDate)
select new Order{
OrderKey = order.OrderKey,
UserEmail = order.UserEmail,
CreatedDate = order.CreatedDate
}

return orderList.ToList();

关于c# - 避免额外的循环并且找不到源类型 int 的查询模式的实现 Select not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14994882/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com