添加abp并发字段在读写分离和分库分表时出现的bug

This commit is contained in:
xuejiaming 2023-03-27 15:12:12 +08:00
parent e9432cb899
commit 4adf709f56
2 changed files with 29 additions and 1 deletions

View File

@ -71,7 +71,7 @@ namespace Sample.MySql
services.AddShardingDbContext<DefaultShardingDbContext>()
.UseRouteConfig(o =>
.UseRouteConfig((sp,o) =>
{
o.AddShardingTableRoute<DynamicTableRoute>();
o.AddShardingTableRoute<SysUserLogByMonthRoute>();

View File

@ -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
}
}
// /// <summary>
// /// abp 5.x+ 如果存在并发字段那么需要添加这段代码
// /// </summary>
// protected override void HandlePropertiesBeforeSave()
// {
// if (GetShardingExecutor() == null)
// {
// base.HandlePropertiesBeforeSave();
// }
// }
// /// <summary>
// /// abp 4.x+ 如果存在并发字段那么需要添加这段代码
// /// </summary>
// /// <returns></returns>
//
// protected override void ApplyAbpConcepts(EntityEntry entry, EntityChangeReport changeReport)
// {
// if (GetShardingExecutor() == null)
// {
// base.ApplyAbpConcepts(entry, changeReport);
// }
// }
public override void Dispose()
{
_shardingDbContextExecutor?.Dispose();