修改readme的提示

This commit is contained in:
xuejiaming 2021-10-25 15:10:57 +08:00
parent b1348cea66
commit 879a2bb5fe
4 changed files with 15 additions and 9 deletions

View File

@ -705,8 +705,11 @@ var shardingPageResultAsync = await _defaultTableDbContext.Set<SysUserMod>().Ord
使用该框架需要注意两点如果你的shardingdbcontext重写了以下服务可能无法使用 如果还想使用需要自己重写扩展[请参考](https://github.com/xuejmnet/sharding-core/blob/main/src/ShardingCore/DIExtension.cs)
1.shardingdbcontext
```c#
return optionsBuilder.ReplaceService<IDbSetSource, ShardingDbSetSource>()
.ReplaceService<IQueryCompiler, ShardingQueryCompiler>();
return optionsBuilder.UseShardingWrapMark()
.ReplaceService<IDbSetSource, ShardingDbSetSource>()
.ReplaceService<IQueryCompiler, ShardingQueryCompiler>()
.ReplaceService<IDbContextTransactionManager, ShardingRelationalTransactionManager<TShardingDbContext>>()
.ReplaceService<IRelationalTransactionFactory, ShardingRelationalTransactionFactory<TShardingDbContext>>();
```
2.defaultdbcontext
```c#
@ -725,12 +728,11 @@ return optionsBuilder.ReplaceService<IModelCacheKeyFactory, ShardingModelCacheKe
- startup是否已经添加虚拟路由
- startup是否已经添加bootstrapper.start()
```c#添加追踪
```c#
//支持最终修改
var sresult = _defaultTableDbContext.Set<SysUserMod>().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

View File

@ -91,7 +91,7 @@ namespace Samples.AbpSharding
return dbContext;
}
private void CheckAndSetShardingKeyThatSupportAutoCreate<TEntity>(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<object> entities)
{
if (isExecutor)

View File

@ -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;

View File

@ -75,7 +75,10 @@ namespace ShardingCore.Helpers
}
/// <summary>
/// check TContext ctor is <see cref="DbContextOptions"/>
/// </summary>
/// <typeparam name="TContext">DbContext</typeparam>
public static void CheckContextConstructors<TContext>()
where TContext : DbContext
{