LINQ中的分组依据错误DbExpressionBinding需要具有集合ResultType的输入表达式。\ r \ n参数名称:input“

时间:2019-02-05 15:06:01

标签: asp.net-mvc entity-framework linq-to-sql

我正在尝试将linq查询分组如下,但我遇到了以上错误,我只发现了几个类似的问题,但我似乎无法弄清楚为什么我遇到了以上错误。

{
"pallet_identifier": 21125,
"shipment_items": [
  {
    "sku": 123456,
    "expected_qty": 45,
    "description": "Ralph Lauren"
  },
  {
    "sku": 246810,
    "expected_qty": 35,
    "description": "Channel No5"
  },
  {
    "sku": 481216,
    "expected_qty": 25,
    "description": "Tommy Hilfinger"
  }
]
}    

我有这个正在使用的课程

public class GoodInWarehouseBM
    {        

        public string pallet_identifier { get; set; }

        public IEnumerable<ShipmentItems> shipment_items { get; set; }

        public class ShipmentItems
        {

            public string sku { get; set; } 

            public decimal stock_qty { get; set; }

            public string description { get; set; }

        }

    }

这是我的LINQ-

var entity = (from consighdrs in mi9TestEntities.consighdrs
                          join consigdests in mi9TestEntities.consigdests on consighdrs.consignment equals consigdests.consignment
                          join consigliness in mi9TestEntities.consiglines on consigdests.condestint equals consigliness.condestint
                          join productcodess in mi9TestEntities.productcodes on consigliness.varint equals productcodess.varint
                          join products in mi9TestEntities.products on productcodess.prodint equals products.prodint
                          orderby consigdests.consignment, productcodess.variantcode
                          where consigdests.destination == storeId && consighdrs.status == "T"
                          select new GoodInWarehouseBM
                          {
                              pallet_identifier = consigdests.consignment,
                              shipment_items = productcodess.variantcode.Select(p => new GoodInWarehouseBM.ShipmentItems
                              {
                                  sku = productcodess.variantcode,
                                  description = products.proddesc,
                                  stock_qty = consigliness.issueqty,
                              })
                          }).ToList();

我猜测代码无法将pallete_identifier下的shipping_items分组,如果是这种情况,由于有大量表在使用中,您能否指出我如何对这个查询进行分组?

0 个答案:

没有答案