移除mysql的多余dbcontext
This commit is contained in:
parent
bbf88d97f5
commit
071a9c9971
|
@ -43,7 +43,7 @@ namespace Sample.MySql.Controllers
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> Get()
|
public async Task<IActionResult> Get()
|
||||||
{
|
{
|
||||||
OtherDbContext.CurrentId = "";
|
//OtherDbContext.CurrentId = "";
|
||||||
// var myUsers0 = _otherDbContext.MyUsers.ToList();
|
// var myUsers0 = _otherDbContext.MyUsers.ToList();
|
||||||
// OtherDbContext.CurrentId = "123";
|
// OtherDbContext.CurrentId = "123";
|
||||||
// var myUsers1 = _otherDbContext.MyUsers.ToList();
|
// var myUsers1 = _otherDbContext.MyUsers.ToList();
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
//using Microsoft.EntityFrameworkCore;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes.RouteTails.Abstractions;
|
//using ShardingCore.Core.VirtualRoutes.TableRoutes.RouteTails.Abstractions;
|
||||||
using ShardingCore.Sharding;
|
//using ShardingCore.Sharding;
|
||||||
using ShardingCore.Sharding.Abstractions;
|
//using ShardingCore.Sharding.Abstractions;
|
||||||
|
|
||||||
namespace Sample.MySql.multi;
|
//namespace Sample.MySql.multi;
|
||||||
|
|
||||||
public class OtherDbContext:AbstractShardingDbContext,IShardingTableDbContext
|
//public class OtherDbContext:AbstractShardingDbContext,IShardingTableDbContext
|
||||||
{
|
//{
|
||||||
public DbSet<MyUser> MyUsers { get; set; }
|
// public DbSet<MyUser> MyUsers { get; set; }
|
||||||
public OtherDbContext(DbContextOptions<OtherDbContext> options) : base(options)
|
// public OtherDbContext(DbContextOptions<OtherDbContext> options) : base(options)
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static string CurrentId;
|
// public static string CurrentId;
|
||||||
public string CID => CurrentId;
|
// public string CID => CurrentId;
|
||||||
public bool HasCID => !string.IsNullOrWhiteSpace(CID);
|
// public bool HasCID => !string.IsNullOrWhiteSpace(CID);
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
// protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
// {
|
||||||
base.OnModelCreating(modelBuilder);
|
// base.OnModelCreating(modelBuilder);
|
||||||
modelBuilder.Entity<MyUser>()
|
// modelBuilder.Entity<MyUser>()
|
||||||
.HasQueryFilter(o => !HasCID || o.Id == CID);
|
// .HasQueryFilter(o => !HasCID || o.Id == CID);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public IRouteTail RouteTail { get; set; }
|
// public IRouteTail RouteTail { get; set; }
|
||||||
}
|
//}
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:1129/",
|
||||||
|
"sslPort": 44318
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Sample.OracleIssue": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||||
"iisSettings": {
|
"iisSettings": {
|
||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
"anonymousAuthentication": true,
|
"anonymousAuthentication": true,
|
||||||
"iisExpress": {
|
"iisExpress": {
|
||||||
"applicationUrl": "http://localhost:34492",
|
"applicationUrl": "http://localhost:1125/",
|
||||||
"sslPort": 44389
|
"sslPort": 44366
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"profiles": {
|
"profiles": {
|
||||||
|
@ -19,13 +19,13 @@
|
||||||
},
|
},
|
||||||
"Samples.AutoByDate.SqlServer": {
|
"Samples.AutoByDate.SqlServer": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": "true",
|
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
},
|
||||||
|
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
||||||
|
"dotnetRunMessages": "true"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue