From 8dd7e685c8d8051f8d9c3139425fc7d2a676bc8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Mon, 16 Jan 2023 16:54:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/Prices/PriceListManager.cs | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs index 7a67c860..2f4324c0 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs @@ -255,20 +255,25 @@ namespace Win.Sfs.SettleAccount.Entities.Prices where itm1.Price != itm2.Price select new PriceList(itm2.Id, itm2.BeginDate, itm2.EndDate, itm1.Price, itm2.MaterialCode, itm2.Type, itm2.ParentId, itm2.Version, itm1.CustomerCode); - if (update.Count() > 0) + var add = from itm1 in entities + join itm2 in pricelist + on new { itm1.Type, itm1.MaterialCode,itm1.CustomerCode } + equals new { itm2.Type, itm2.MaterialCode,itm2.CustomerCode } + into temp + from itm3 in temp.DefaultIfEmpty() + where itm3 == null + select itm1; + + + + + if (update!=null&& update.Count() > 0) { await _repository.GetDbContext().BulkUpdateAsync(update.ToList()); } - else + if(add!=null && add.Count()>0) { - var add = from itm1 in entities - join itm2 in pricelist - on new { itm1.Type, itm1.MaterialCode } - equals new { itm2.Type, itm2.MaterialCode } - into temp - from itm3 in temp.DefaultIfEmpty() - where itm3 == null - select itm1; + await _repository.GetDbContext().BulkInsertAsync(add.ToList()); }