删除demo的测试代码
This commit is contained in:
parent
be652568c3
commit
8e4a853619
|
@ -268,5 +268,14 @@ namespace Sample.MySql.Controllers
|
|||
// var sysUserMods2 = await _defaultTableDbContext.Set<SysTest>().FromSqlRaw("select * from SysTest where id='2'").ToListAsync();
|
||||
return Ok();
|
||||
}
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Get8()
|
||||
{
|
||||
var list = new List<string>();
|
||||
var sysUserMod = await _defaultTableDbContext.Set<SysTest>().Where(o => list.Contains(o.Id)).ToListAsync();
|
||||
// var sysUserMods1 = await _defaultTableDbContext.Set<SysUserMod>().FromSqlRaw("select * from SysUserMod where id='2'").ToListAsync();
|
||||
// var sysUserMods2 = await _defaultTableDbContext.Set<SysTest>().FromSqlRaw("select * from SysTest where id='2'").ToListAsync();
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,11 +26,6 @@ namespace Sample.MySql.DbContexts
|
|||
//Database.SetCommandTimeout(30000);
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
this.GetShardingRuntimeContext().GetOrCreateShardingRuntimeModel(this);
|
||||
}
|
||||
|
||||
private readonly MethodInfo? _configureGlobalFiltersMethodInfo =
|
||||
typeof(DefaultShardingDbContext).GetMethod(nameof(ConfigureGlobalFilters),
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ShardingCore.Sharding.Abstractions;
|
||||
|
||||
namespace ShardingCore.Sharding
|
||||
{
|
||||
public class ShardingDbContextOptionsBuilderConfigure<TShardingDbContext> where TShardingDbContext : DbContext, IShardingDbContext
|
||||
{
|
||||
public ShardingDbContextOptionsBuilderConfigure(Action<DbConnection, DbContextOptionsBuilder> sameConnectionDbContextOptionsCreator, Action<string, DbContextOptionsBuilder> defaultQueryDbContextOptionsCreator)
|
||||
{
|
||||
SameConnectionDbContextOptionsCreator = sameConnectionDbContextOptionsCreator;
|
||||
DefaultQueryDbContextOptionsCreator = defaultQueryDbContextOptionsCreator;
|
||||
}
|
||||
public Action<DbConnection, DbContextOptionsBuilder> SameConnectionDbContextOptionsCreator { get; }
|
||||
public Action<string, DbContextOptionsBuilder> DefaultQueryDbContextOptionsCreator { get; }
|
||||
|
||||
public DbContextOptionsBuilder UseDbContextOptionsBuilder(DbConnection dbConnection, DbContextOptionsBuilder dbContextOptionsBuilder)
|
||||
{
|
||||
SameConnectionDbContextOptionsCreator(dbConnection, dbContextOptionsBuilder);
|
||||
dbContextOptionsBuilder.UseInnerDbContextSharding();
|
||||
return dbContextOptionsBuilder;
|
||||
}
|
||||
|
||||
public DbContextOptionsBuilder UseDbContextOptionsBuilder(string connectionString, DbContextOptionsBuilder dbContextOptionsBuilder)
|
||||
{
|
||||
DefaultQueryDbContextOptionsCreator(connectionString, dbContextOptionsBuilder);
|
||||
dbContextOptionsBuilder.UseInnerDbContextSharding();
|
||||
return dbContextOptionsBuilder;
|
||||
}
|
||||
}
|
||||
}
|
||||
// using System;
|
||||
// using System.Collections.Generic;
|
||||
// using System.Data.Common;
|
||||
// using System.Linq;
|
||||
// using System.Text;
|
||||
// using System.Threading.Tasks;
|
||||
// using Microsoft.EntityFrameworkCore;
|
||||
// using ShardingCore.Sharding.Abstractions;
|
||||
//
|
||||
// namespace ShardingCore.Sharding
|
||||
// {
|
||||
// public class ShardingDbContextOptionsBuilderConfigure<TShardingDbContext> where TShardingDbContext : DbContext, IShardingDbContext
|
||||
// {
|
||||
// public ShardingDbContextOptionsBuilderConfigure(Action<DbConnection, DbContextOptionsBuilder> sameConnectionDbContextOptionsCreator, Action<string, DbContextOptionsBuilder> defaultQueryDbContextOptionsCreator)
|
||||
// {
|
||||
// SameConnectionDbContextOptionsCreator = sameConnectionDbContextOptionsCreator;
|
||||
// DefaultQueryDbContextOptionsCreator = defaultQueryDbContextOptionsCreator;
|
||||
// }
|
||||
// public Action<DbConnection, DbContextOptionsBuilder> SameConnectionDbContextOptionsCreator { get; }
|
||||
// public Action<string, DbContextOptionsBuilder> DefaultQueryDbContextOptionsCreator { get; }
|
||||
//
|
||||
// public DbContextOptionsBuilder UseDbContextOptionsBuilder(DbConnection dbConnection, DbContextOptionsBuilder dbContextOptionsBuilder)
|
||||
// {
|
||||
// SameConnectionDbContextOptionsCreator(dbConnection, dbContextOptionsBuilder);
|
||||
// dbContextOptionsBuilder.UseInnerDbContextSharding();
|
||||
// return dbContextOptionsBuilder;
|
||||
// }
|
||||
//
|
||||
// public DbContextOptionsBuilder UseDbContextOptionsBuilder(string connectionString, DbContextOptionsBuilder dbContextOptionsBuilder)
|
||||
// {
|
||||
// DefaultQueryDbContextOptionsCreator(connectionString, dbContextOptionsBuilder);
|
||||
// dbContextOptionsBuilder.UseInnerDbContextSharding();
|
||||
// return dbContextOptionsBuilder;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
Loading…
Reference in New Issue