zoukankan      html  css  js  c++  java
  • .net core2.x 元组不能在表达树使用

    错误信息 Cannot resolve method Void .ctor(Int32, Int32, System.Decimal, System.Decimal) because the declaring type of the method handle System.ValueTuple`4[T1,T2,T3,T4] is generic. Explicitly provide the declaring type to GetMethodFromHandle

    在本地可以运行,测试环境就不行,因为本地我装了privew 5 版本测试环境是2.1
    https://github.com/dotnet/runtime/issues/29220
    代码如下

    
     public async Task<(int QtySum, int CartonsSum, decimal VolumeSum, decimal WeightSum)> GetCountSumByItemIds(List<int> itemIds) 
     {
       // core 2.x错误示例  
       var result = from o in _context.Orders
                     join info in _context.TransportInfos on o.Id equals info.OrderId
                     join item in _context.TransportItems on info.Id equals item.TransportId
                     where itemIds.Contains(item.Id)
                     select new Valuetuple<int, int, decimal, decimal>(o.QuantitySum.Value, o.CartonsSum.Value, o.VolumeSum, o.WeightSum);
       return await result.FirstOrDefaultAsync();         
     }
    
    
    public async Task<(int QtySum, int CartonsSum, decimal VolumeSum, decimal WeightSum)> GetCountSumByItemIds(List<int> itemIds) 
    {
        var result = from o in _context.Orders
                     join info in _context.TransportInfos on o.Id equals info.OrderId
                     join item in _context.TransportItems on info.Id equals item.TransportId
                     where itemIds.Contains(item.Id)
                     select new Tuple<int, int, decimal, decimal>(o.QuantitySum.Value, o.CartonsSum.Value, o.VolumeSum, o.WeightSum);
    
       // core 2.X 不支持 在表达树中写new Valuetuple<>()
       var copyTuple = await result.FirstOrDefaultAsync();
       return copyTuple.ToValueTuple();
    }
    
  • 相关阅读:
    HTML <input> 标签
    HTML5 <input> type 属性
    静态页面与动态页面
    string::size_type 页73 size_t 页90
    template method(模板方法)
    C++中创建对象的时候加括号和不加括号的区别(转)
    _declspec(dllexport)和.def(转)
    智能指针
    C++中的delete加深认识
    工厂方法(整理自李建忠<C++设计模式>视频)
  • 原文地址:https://www.cnblogs.com/caiyangcc/p/13204265.html
Copyright © 2011-2022 走看看