亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

通過具有分組的特定屬性從列表中刪除另一個列表中的項目

通過具有分組的特定屬性從列表中刪除另一個列表中的項目

C#
慕的地8271018 2022-10-23 15:41:04
我有兩個清單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
查看完整描述

2 回答

?
子衿沉夜

TA貢獻1828條經驗 獲得超3個贊

你可以嘗試使用.Where(i=> getConsignmentbookedin.Any(z=> z != i.pallet_identifier))


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

                        {

                            pallet_identifier = grp.Key,

                            shipment_items = grp.Select(a => new GoodInWarehouseBM.ShipmentItems

                            {

                                sku = a.productcodess.variantcode,

                                stock_qty = a.consigliness.issueqty,

                                description = a.products.proddesc


                            }).ToList()


                        }).Where(i=> getConsignmentbookedin.Any(z=> z != i.pallet_identifier)).ToList();



查看完整回答
反對 回復 2022-10-23
?
慕慕森

TA貢獻1856條經驗 獲得超17個贊

您應該在組和選擇之前應用過濾器,因為您丟棄了不需要的所有內容,所以它會大大提高您的查詢。


entity = new List<GoodInWarehouseBM>((from consighdrs in mi9db.consighdrs.Where(i=> !getConsignmentbookedin.Contains(i.Id(id of item not sure which one it is))

                        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

                        {

                            pallet_identifier = grp.Key,

                            shipment_items = grp.Select(a => new GoodInWarehouseBM.ShipmentItems

                            {

                                sku = a.productcodess.variantcode,

                                stock_qty = a.consigliness.issueqty,

                                description = a.products.proddesc


                            }).ToList()


                        })).ToList();


查看完整回答
反對 回復 2022-10-23
  • 2 回答
  • 0 關注
  • 118 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號