diff --git a/samples/Sample.MySql/Controllers/WeatherForecastController.cs b/samples/Sample.MySql/Controllers/WeatherForecastController.cs index 9bea3ff2..0921dabb 100644 --- a/samples/Sample.MySql/Controllers/WeatherForecastController.cs +++ b/samples/Sample.MySql/Controllers/WeatherForecastController.cs @@ -268,5 +268,14 @@ namespace Sample.MySql.Controllers // var sysUserMods2 = await _defaultTableDbContext.Set().FromSqlRaw("select * from SysTest where id='2'").ToListAsync(); return Ok(); } + [HttpGet] + public async Task Get8() + { + var list = new List(); + var sysUserMod = await _defaultTableDbContext.Set().Where(o => list.Contains(o.Id)).ToListAsync(); + // var sysUserMods1 = await _defaultTableDbContext.Set().FromSqlRaw("select * from SysUserMod where id='2'").ToListAsync(); + // var sysUserMods2 = await _defaultTableDbContext.Set().FromSqlRaw("select * from SysTest where id='2'").ToListAsync(); + return Ok(); + } } } diff --git a/samples/Sample.MySql/DbContexts/DefaultShardingDbContext.cs b/samples/Sample.MySql/DbContexts/DefaultShardingDbContext.cs index 528716d1..c4f06bbc 100644 --- a/samples/Sample.MySql/DbContexts/DefaultShardingDbContext.cs +++ b/samples/Sample.MySql/DbContexts/DefaultShardingDbContext.cs @@ -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), diff --git a/src/ShardingCore/Sharding/ShardingDbContextOptionsBuilderConfigure.cs b/src/ShardingCore/Sharding/ShardingDbContextOptionsBuilderConfigure.cs index d20e2f59..24e3f9c2 100644 --- a/src/ShardingCore/Sharding/ShardingDbContextOptionsBuilderConfigure.cs +++ b/src/ShardingCore/Sharding/ShardingDbContextOptionsBuilderConfigure.cs @@ -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 where TShardingDbContext : DbContext, IShardingDbContext - { - public ShardingDbContextOptionsBuilderConfigure(Action sameConnectionDbContextOptionsCreator, Action defaultQueryDbContextOptionsCreator) - { - SameConnectionDbContextOptionsCreator = sameConnectionDbContextOptionsCreator; - DefaultQueryDbContextOptionsCreator = defaultQueryDbContextOptionsCreator; - } - public Action SameConnectionDbContextOptionsCreator { get; } - public Action 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 where TShardingDbContext : DbContext, IShardingDbContext +// { +// public ShardingDbContextOptionsBuilderConfigure(Action sameConnectionDbContextOptionsCreator, Action defaultQueryDbContextOptionsCreator) +// { +// SameConnectionDbContextOptionsCreator = sameConnectionDbContextOptionsCreator; +// DefaultQueryDbContextOptionsCreator = defaultQueryDbContextOptionsCreator; +// } +// public Action SameConnectionDbContextOptionsCreator { get; } +// public Action 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; +// } +// } +// }