From 4adf709f560e181876da4650793fba9a657ce01b Mon Sep 17 00:00:00 2001 From: xuejiaming <326308290@qq.com> Date: Mon, 27 Mar 2023 15:12:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0abp=E5=B9=B6=E5=8F=91?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=9C=A8=E8=AF=BB=E5=86=99=E5=88=86=E7=A6=BB?= =?UTF-8?q?=E5=92=8C=E5=88=86=E5=BA=93=E5=88=86=E8=A1=A8=E6=97=B6=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- samples/Sample.MySql/Startup.cs | 2 +- .../AbstractShardingAbpDbContext.cs | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/samples/Sample.MySql/Startup.cs b/samples/Sample.MySql/Startup.cs index ce572fb0..594011e0 100644 --- a/samples/Sample.MySql/Startup.cs +++ b/samples/Sample.MySql/Startup.cs @@ -71,7 +71,7 @@ namespace Sample.MySql services.AddShardingDbContext() - .UseRouteConfig(o => + .UseRouteConfig((sp,o) => { o.AddShardingTableRoute(); o.AddShardingTableRoute(); diff --git a/samples/Samples.AbpSharding/AbstractShardingAbpDbContext.cs b/samples/Samples.AbpSharding/AbstractShardingAbpDbContext.cs index 2b7db47b..adb82b66 100644 --- a/samples/Samples.AbpSharding/AbstractShardingAbpDbContext.cs +++ b/samples/Samples.AbpSharding/AbstractShardingAbpDbContext.cs @@ -5,9 +5,11 @@ using System; using System.ComponentModel.DataAnnotations.Schema; using System.Threading.Tasks; using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore.ChangeTracking; using ShardingCore.EFCores; using ShardingCore.Sharding.ShardingDbContextExecutors; using Volo.Abp.Domain.Entities; +using Volo.Abp.Domain.Entities.Events; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.Reflection; @@ -101,6 +103,32 @@ namespace Samples.AbpSharding } } + + // /// + // /// abp 5.x+ 如果存在并发字段那么需要添加这段代码 + // /// + // protected override void HandlePropertiesBeforeSave() + // { + // if (GetShardingExecutor() == null) + // { + // base.HandlePropertiesBeforeSave(); + // } + // } + + + // /// + // /// abp 4.x+ 如果存在并发字段那么需要添加这段代码 + // /// + // /// + // + // protected override void ApplyAbpConcepts(EntityEntry entry, EntityChangeReport changeReport) + // { + // if (GetShardingExecutor() == null) + // { + // base.ApplyAbpConcepts(entry, changeReport); + // } + // } + public override void Dispose() { _shardingDbContextExecutor?.Dispose();