diff --git a/README.md b/README.md index 6db16ead..084846ae 100644 --- a/README.md +++ b/README.md @@ -705,8 +705,11 @@ var shardingPageResultAsync = await _defaultTableDbContext.Set().Ord 使用该框架需要注意两点如果你的shardingdbcontext重写了以下服务可能无法使用 如果还想使用需要自己重写扩展[请参考](https://github.com/xuejmnet/sharding-core/blob/main/src/ShardingCore/DIExtension.cs) 1.shardingdbcontext ```c# - return optionsBuilder.ReplaceService() - .ReplaceService(); + return optionsBuilder.UseShardingWrapMark() + .ReplaceService() + .ReplaceService() + .ReplaceService>() + .ReplaceService>(); ``` 2.defaultdbcontext ```c# @@ -725,12 +728,11 @@ return optionsBuilder.ReplaceService().ToList(); var sysUserMod98 = result.FirstOrDefault(o => o.Id == "98"); - _defaultTableDbContext.Attach(sysUserMod98);//添加追踪 sysUserMod98.Name = "name_update"+new Random().Next(1,99)+"_98"; await _defaultTableDbContext.SaveChangesAsync(); --log info diff --git a/samples/Samples.AbpSharding/AbstractShardingAbpDbContext.cs b/samples/Samples.AbpSharding/AbstractShardingAbpDbContext.cs index 78d1839e..7d946383 100644 --- a/samples/Samples.AbpSharding/AbstractShardingAbpDbContext.cs +++ b/samples/Samples.AbpSharding/AbstractShardingAbpDbContext.cs @@ -91,7 +91,7 @@ namespace Samples.AbpSharding return dbContext; } - + private void CheckAndSetShardingKeyThatSupportAutoCreate(TEntity entity) where TEntity : class { @@ -122,7 +122,8 @@ namespace Samples.AbpSharding true ); } - }else if (entity is IShardingKeyIsCreationTime) + } + else if (entity is IShardingKeyIsCreationTime) { AuditPropertySetter?.SetCreationProperties(entity); } @@ -180,7 +181,6 @@ namespace Samples.AbpSharding group.Key.AddRange(group.Select(o => o.Entity)); } } - public override void AddRange(IEnumerable entities) { if (isExecutor) diff --git a/src/ShardingCore/DIExtension.cs b/src/ShardingCore/DIExtension.cs index 94f6fea8..dd1927c7 100644 --- a/src/ShardingCore/DIExtension.cs +++ b/src/ShardingCore/DIExtension.cs @@ -24,6 +24,7 @@ using ShardingCore.Sharding.Abstractions; using ShardingCore.Sharding.ShardingQueryExecutors; using ShardingCore.TableCreator; using System; +using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Storage; using ShardingCore.EFCores.OptionsExtensions; diff --git a/src/ShardingCore/Helpers/ShardingCoreHelper.cs b/src/ShardingCore/Helpers/ShardingCoreHelper.cs index 2d6f5ba4..7f667f06 100644 --- a/src/ShardingCore/Helpers/ShardingCoreHelper.cs +++ b/src/ShardingCore/Helpers/ShardingCoreHelper.cs @@ -75,7 +75,10 @@ namespace ShardingCore.Helpers } - + /// + /// check TContext ctor is + /// + /// DbContext public static void CheckContextConstructors() where TContext : DbContext {