This commit is contained in:
xuejiaming 2021-08-23 08:18:17 +08:00
parent 085e22bb88
commit 701043b41c
4 changed files with 14 additions and 11 deletions

View File

@ -322,7 +322,7 @@ AbstractSimpleShardingYearKeyLongVirtualTableRoute |按时间戳 |yyyy | `>,>=,<
{
op.EnsureCreatedWithOutShardingTable = true;
op.CreateShardingTableOnStart = true;
op.UseShardingOptionsBuilder((connection, builder) => builder.UseSqlServer("write db connection string").UseLoggerFactory(efLogger),
op.UseShardingOptionsBuilder((connection, builder) => builder.UseSqlServer(connection).UseLoggerFactory(efLogger),
(conStr,builder)=> builder.UseSqlServer("read db connection string").UseLoggerFactory(efLogger));
op.AddShardingTableRoute<SysUserModVirtualTableRoute>();
op.AddShardingTableRoute<SysUserSalaryVirtualTableRoute>();

View File

@ -21,7 +21,6 @@ namespace Sample.SqlServer.DbContexts
{
base.OnModelCreating(modelBuilder);
modelBuilder.ApplyConfiguration(new SysUserModMap());
modelBuilder.ApplyConfiguration(new SysTestMap());
}
public IRouteTail RouteTail { get; set; }

View File

@ -3,13 +3,16 @@ using ShardingCore.Core;
namespace Sample.SqlServer.Domain.Entities
{
/*
* @Author: xjm
* @Description:
* @Date: Tuesday, 26 January 2021 12:25:39
* @Email: 326308290@qq.com
*/
public class SysUserMod:IShardingTable
/*
* @Author: xjm
* @Description:
* @Date: Tuesday, 26 January 2021 12:25:39
* @Email: 326308290@qq.com
*/
/// <summary>
/// 用户表
/// </summary>
public class SysUserMod : IShardingTable
{
/// <summary>
/// 用户Id用于分表

View File

@ -30,8 +30,9 @@ namespace Sample.SqlServer
{
op.EnsureCreatedWithOutShardingTable = true;
op.CreateShardingTableOnStart = true;
op.UseShardingOptionsBuilder((connection, builder) => builder.UseSqlServer(connection).UseLoggerFactory(efLogger),
(conStr,builder) => builder.UseSqlServer(conStr).UseLoggerFactory(efLogger));
op.UseShardingOptionsBuilder(
(connection, builder) => builder.UseSqlServer(connection).UseLoggerFactory(efLogger),//使用dbconnection创建dbcontext支持事务
(conStr,builder) => builder.UseSqlServer(conStr).UseLoggerFactory(efLogger));//使用链接字符串创建dbcontext
op.AddShardingTableRoute<SysUserModVirtualTableRoute>();
});
////不支持MARS不支持追踪的