通过具有分组的特定属性从列表中删除另一个列表中的项目

我有两个清单


List A (CG300019159, CG300018158, FS300076458)

List B Returns grouped lists like below

     {

            "pallet_identifier": "CG300018158",

            "shipment_items": [

                {

                    "sku": "10366960",

                    "stock_qty": 12,

                    "description": "MOTHERCARE CREAM BABYGROW W/HAT"

                },

                {

                    "sku": "10346788",

                    "stock_qty": 1,

                    "description": "KIT 7PC ESS CREW NECK CARDIGAN SKY BLUE"

                }

    ]

    },

    "pallet_identifier": "CG300018187",

            "shipment_items": [

                {

                    "sku": "10366960",

                    "stock_qty": 12,

                    "description": "MOTHERCARE CREAM BABYGROW W/HAT"

                },

                {

                    "sku": "10346788",

                    "stock_qty": 1,

                    "description": "KIT 7PC ESS CREW NECK CARDIGAN SKY BLUE"

                }

    ]

    },

我想使用属性pallet_identifier 从列表B 中删除托盘及其内容。


尝试如下


entity = new List<GoodInWarehouseBM>((from consighdrs in mi9db.consighdrs

                        join consigdests in mi9db.consigdests on consighdrs.consignment equals consigdests

                            .consignment

                        join consigliness in mi9db.consiglines on consigdests.condestint equals consigliness

                            .condestint

                        join productcodess in mi9db.productcodes on consigliness.varint equals productcodess.varint

                        join products in mi9db.products on productcodess.prodint equals products.prodint

                        where consigdests.destination == storeId && consighdrs.status == "T" && consighdrs.warehouse == "900"

                        group new { consigdests, productcodess, consigliness, products } by consigdests.consignment into grp

                        select new GoodInWarehouseBM




慕的地8271018
浏览 159回答 2
2回答

子衿沉夜

你可以尝试使用.Where(i=> getConsignmentbookedin.Any(z=> z != i.pallet_identifier))entity = new List<GoodInWarehouseBM>((from consighdrs in mi9db.consighdrs&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; join consigdests in mi9db.consigdests on consighdrs.consignment equals consigdests&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .consignment&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; join consigliness in mi9db.consiglines on consigdests.condestint equals consigliness&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .condestint&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; join productcodess in mi9db.productcodes on consigliness.varint equals productcodess.varint&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; join products in mi9db.products on productcodess.prodint equals products.prodint&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; where consigdests.destination == storeId && consighdrs.status == "T" && consighdrs.warehouse == "900"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; group new { consigdests, productcodess, consigliness, products } by consigdests.consignment into grp&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; select new GoodInWarehouseBM&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pallet_identifier = grp.Key,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shipment_items = grp.Select(a => new GoodInWarehouseBM.ShipmentItems&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sku = a.productcodess.variantcode,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stock_qty = a.consigliness.issueqty,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; description = a.products.proddesc&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }).ToList()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }).Where(i=> getConsignmentbookedin.Any(z=> z != i.pallet_identifier)).ToList();

慕慕森

您应该在组和选择之前应用过滤器,因为您丢弃了不需要的所有内容,所以它会大大提高您的查询。entity = new List<GoodInWarehouseBM>((from consighdrs in mi9db.consighdrs.Where(i=> !getConsignmentbookedin.Contains(i.Id(id of item not sure which one it is))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; join consigdests in mi9db.consigdests on consighdrs.consignment equals consigdests&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .consignment&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; join consigliness in mi9db.consiglines on consigdests.condestint equals consigliness&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .condestint&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; join productcodess in mi9db.productcodes on consigliness.varint equals productcodess.varint&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; join products in mi9db.products on productcodess.prodint equals products.prodint&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; where consigdests.destination == storeId && consighdrs.status == "T" && consighdrs.warehouse == "900"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; group new { consigdests, productcodess, consigliness, products } by consigdests.consignment into grp&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; select new GoodInWarehouseBM&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pallet_identifier = grp.Key,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shipment_items = grp.Select(a => new GoodInWarehouseBM.ShipmentItems&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sku = a.productcodess.variantcode,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stock_qty = a.consigliness.issueqty,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; description = a.products.proddesc&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }).ToList()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })).ToList();
打开App,查看更多内容
随时随地看视频慕课网APP