From ff307db8792cb1230b21ca8b6b2b439861445752 Mon Sep 17 00:00:00 2001 From: xuejiaming <326308290@qq.com> Date: Sun, 27 Nov 2022 00:00:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=88=B07.6.0.8=E7=A7=BB?= =?UTF-8?q?=E9=99=A4IShardingModelCacheOption=EF=BC=8C=E5=B0=86=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=9A=84=E7=BC=93=E5=AD=98=E8=AE=BE=E7=BD=AE=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E4=BA=86=E5=BB=BA=E8=AE=AE=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nuget-publish.bat | 10 ++-- .../Shardings/SysUserLogByMonthRoute.cs | 22 +++++--- .../Core/IShardingModelCacheOption.cs | 24 --------- .../DefaultModelCacheLockerProvider.cs | 18 +++++++ .../IModelCacheLockerProvider.cs | 9 ++++ .../ShardingConfigOptions.cs | 15 ++++++ .../EFCores/EFCore2x/ShardingModelSource.cs | 9 ++-- .../EFCores/EFCore3x/ShardingModelSource.cs | 21 +++----- .../EFCores/EFCore5x/ShardingModelSource.cs | 19 +++---- .../EFCores/EFCore6x/ShardingModelSource.cs | 48 +++-------------- .../EFCores/EFCore7x/ShardingModelSource.cs | 48 +++++++++-------- .../EFCores/IShardingModelSource.cs | 17 ------ .../DbContextExtensionShardingCore.cs | 52 ------------------- src/ShardingCore/ShardingCore.csproj | 2 +- src2/ShardingCore2/ShardingCore2.csproj | 2 +- src3/ShardingCore3/ShardingCore3.csproj | 2 +- src5/ShardingCore5/ShardingCore5.csproj | 2 +- src6/ShardingCore6/ShardingCore6.csproj | 2 +- 18 files changed, 119 insertions(+), 203 deletions(-) delete mode 100644 src/ShardingCore/Core/IShardingModelCacheOption.cs delete mode 100644 src/ShardingCore/EFCores/IShardingModelSource.cs diff --git a/nuget-publish.bat b/nuget-publish.bat index 5bca14df..674832ed 100644 --- a/nuget-publish.bat +++ b/nuget-publish.bat @@ -1,10 +1,10 @@ :start ::定义版本 -set EFCORE7=7.7.0.7 -set EFCORE6=7.6.0.7 -set EFCORE5=7.5.0.7 -set EFCORE3=7.3.0.7 -set EFCORE2=7.2.0.7 +set EFCORE7=7.7.0.8 +set EFCORE6=7.6.0.8 +set EFCORE5=7.5.0.8 +set EFCORE3=7.3.0.8 +set EFCORE2=7.2.0.8 ::删除所有bin与obj下的文件 @echo off diff --git a/samples/Sample.MySql/Shardings/SysUserLogByMonthRoute.cs b/samples/Sample.MySql/Shardings/SysUserLogByMonthRoute.cs index 53655b6c..a6958238 100644 --- a/samples/Sample.MySql/Shardings/SysUserLogByMonthRoute.cs +++ b/samples/Sample.MySql/Shardings/SysUserLogByMonthRoute.cs @@ -34,16 +34,22 @@ namespace Sample.MySql.Shardings builder.ShardingProperty(o => o.Time); } + // protected override List AfterShardingRouteUnitFilter(DataSourceRouteResult dataSourceRouteResult, List shardingRouteUnits) + // { + // if (shardingRouteUnits.Count > 10) + // { + // _logger.LogInformation("截断前:"+string.Join(",",shardingRouteUnits.Select(o=>o.Tail))); + // //这边你要自己做顺序处理阶段 + // var result= shardingRouteUnits.OrderByDescending(o=>o.Tail).Take(10).ToList(); + // _logger.LogInformation("截断后:"+string.Join(",",result.Select(o=>o.Tail))); + // return result; + // } + // return base.AfterShardingRouteUnitFilter(dataSourceRouteResult, shardingRouteUnits); + // } + protected override List AfterShardingRouteUnitFilter(DataSourceRouteResult dataSourceRouteResult, List shardingRouteUnits) { - if (shardingRouteUnits.Count > 10) - { - _logger.LogInformation("截断前:"+string.Join(",",shardingRouteUnits.Select(o=>o.Tail))); - //这边你要自己做顺序处理阶段 - var result= shardingRouteUnits.OrderByDescending(o=>o.Tail).Take(10).ToList(); - _logger.LogInformation("截断后:"+string.Join(",",result.Select(o=>o.Tail))); - return result; - } + Console.WriteLine("AfterShardingRouteUnitFilter:"+shardingRouteUnits.Count); return base.AfterShardingRouteUnitFilter(dataSourceRouteResult, shardingRouteUnits); } } diff --git a/src/ShardingCore/Core/IShardingModelCacheOption.cs b/src/ShardingCore/Core/IShardingModelCacheOption.cs deleted file mode 100644 index f3770f55..00000000 --- a/src/ShardingCore/Core/IShardingModelCacheOption.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Extensions.Caching.Memory; - -namespace ShardingCore.Core -{ - /// - /// - /// - /// Author: xjm - /// Created: 2022/4/15 11:40:58 - /// Email: 326308290@qq.com - public interface IShardingModelCacheOption - { -#if !EFCORE2 - CacheItemPriority GetModelCachePriority(); - int GetModelCacheEntrySize(); -#endif - int GetModelCacheLockObjectSeconds(); - } -} diff --git a/src/ShardingCore/Core/ModelCacheLockerProviders/DefaultModelCacheLockerProvider.cs b/src/ShardingCore/Core/ModelCacheLockerProviders/DefaultModelCacheLockerProvider.cs index 4a18c407..e25e9a5c 100644 --- a/src/ShardingCore/Core/ModelCacheLockerProviders/DefaultModelCacheLockerProvider.cs +++ b/src/ShardingCore/Core/ModelCacheLockerProviders/DefaultModelCacheLockerProvider.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; +using Microsoft.Extensions.Caching.Memory; using ShardingCore.Core.ShardingConfigurations; using ShardingCore.Exceptions; @@ -26,6 +27,23 @@ namespace ShardingCore.Core.ModelCacheLockerProviders _locks.Add(new object()); } } + + public int GetModelCacheLockObjectSeconds() + { + return _shardingConfigOptions.ModelCacheLockObjectSeconds; + } + +#if !EFCORE2 + public CacheItemPriority GetCacheItemPriority() + { + return _shardingConfigOptions.CacheItemPriority; + } + + public int GetCacheEntrySize() + { + return _shardingConfigOptions.CacheEntrySize; + } +#endif public object GetCacheLockObject(object modelCacheKey) { if (modelCacheKey == null) diff --git a/src/ShardingCore/Core/ModelCacheLockerProviders/IModelCacheLockerProvider.cs b/src/ShardingCore/Core/ModelCacheLockerProviders/IModelCacheLockerProvider.cs index 162a63db..f71b9648 100644 --- a/src/ShardingCore/Core/ModelCacheLockerProviders/IModelCacheLockerProvider.cs +++ b/src/ShardingCore/Core/ModelCacheLockerProviders/IModelCacheLockerProvider.cs @@ -1,7 +1,16 @@ +using Microsoft.Extensions.Caching.Memory; + namespace ShardingCore.Core.ModelCacheLockerProviders { public interface IModelCacheLockerProvider { + int GetModelCacheLockObjectSeconds(); +#if !EFCORE2 + CacheItemPriority GetCacheItemPriority(); + int GetCacheEntrySize(); + +#endif + object GetCacheLockObject(object modelCacheKey); } } diff --git a/src/ShardingCore/Core/ShardingConfigurations/ShardingConfigOptions.cs b/src/ShardingCore/Core/ShardingConfigurations/ShardingConfigOptions.cs index 4088fb2c..50300b53 100644 --- a/src/ShardingCore/Core/ShardingConfigurations/ShardingConfigOptions.cs +++ b/src/ShardingCore/Core/ShardingConfigurations/ShardingConfigOptions.cs @@ -3,6 +3,7 @@ using ShardingCore.Sharding.ReadWriteConfigurations; using System; using System.Collections.Generic; using System.Data.Common; +using Microsoft.Extensions.Caching.Memory; using ShardingCore.Core.ServiceProviders; namespace ShardingCore.Core.ShardingConfigurations @@ -12,6 +13,20 @@ namespace ShardingCore.Core.ShardingConfigurations /// public class ShardingConfigOptions { + /// + /// 模型缓存锁等待时间 + /// + public int ModelCacheLockObjectSeconds { get; set; } = 3; +#if !EFCORE2 + /// + /// 模型缓存的优先级 + /// + public CacheItemPriority CacheItemPriority { get; set; } = CacheItemPriority.High; + /// + /// efcore缓存最多限制10240个,单个缓存size设置为10那么就意味可以最多统一时间缓存1024个(缓存过期了那么还是会可以缓存进去的) + /// + public int CacheEntrySize { get; set; } = 10; +#endif /// /// 模型缓存锁等级 /// diff --git a/src/ShardingCore/EFCores/EFCore2x/ShardingModelSource.cs b/src/ShardingCore/EFCores/EFCore2x/ShardingModelSource.cs index 6ec22b0e..49a21021 100644 --- a/src/ShardingCore/EFCores/EFCore2x/ShardingModelSource.cs +++ b/src/ShardingCore/EFCores/EFCore2x/ShardingModelSource.cs @@ -58,16 +58,13 @@ namespace ShardingCore.EFCores } } - int waitSeconds = 3; var cacheKey = Dependencies.ModelCacheKeyFactory.Create(context); if (!_models.TryGetValue(cacheKey, out var model)) { - if (context is IShardingModelCacheOption shardingModelCacheOption) - { - waitSeconds = shardingModelCacheOption.GetModelCacheLockObjectSeconds(); - } - var cacheLockObject = _shardingRuntimeContext.GetModelCacheLockerProvider().GetCacheLockObject(cacheKey); + var modelCacheLockerProvider = _shardingRuntimeContext.GetModelCacheLockerProvider(); + var waitSeconds = modelCacheLockerProvider.GetModelCacheLockObjectSeconds(); + var cacheLockObject = modelCacheLockerProvider.GetCacheLockObject(cacheKey); var acquire = Monitor.TryEnter(cacheLockObject, TimeSpan.FromSeconds(waitSeconds)); if (!acquire) { diff --git a/src/ShardingCore/EFCores/EFCore3x/ShardingModelSource.cs b/src/ShardingCore/EFCores/EFCore3x/ShardingModelSource.cs index b8dd245c..104d77fe 100644 --- a/src/ShardingCore/EFCores/EFCore3x/ShardingModelSource.cs +++ b/src/ShardingCore/EFCores/EFCore3x/ShardingModelSource.cs @@ -49,9 +49,7 @@ namespace ShardingCore.EFCores DbContext context, IConventionSetBuilder conventionSetBuilder) { - var priority = CacheItemPriority.High; - var size = 200; - var waitSeconds = 3; + CacheItemPriority? setPriority = null; if (context is IShardingTableDbContext shardingTableDbContext) { if (shardingTableDbContext.RouteTail is null) @@ -65,22 +63,19 @@ namespace ShardingCore.EFCores } else if (shardingTableDbContext.RouteTail is ISingleQueryRouteTail singleQueryRouteTail && singleQueryRouteTail.IsShardingTableQuery()) { - priority = CacheItemPriority.Normal; + setPriority = CacheItemPriority.Normal; } } var cache = Dependencies.MemoryCache; var cacheKey = Dependencies.ModelCacheKeyFactory.Create(context); if (!cache.TryGetValue(cacheKey, out IModel model)) { - if (context is IShardingModelCacheOption shardingModelCacheOption) - { - priority = shardingModelCacheOption.GetModelCachePriority(); - size = shardingModelCacheOption.GetModelCacheEntrySize(); - waitSeconds = shardingModelCacheOption.GetModelCacheLockObjectSeconds(); - } - // Make sure OnModelCreating really only gets called once, since it may not be thread safe. - - var cacheLockObject = _shardingRuntimeContext.GetModelCacheLockerProvider().GetCacheLockObject(cacheKey); + + var modelCacheLockerProvider = _shardingRuntimeContext.GetModelCacheLockerProvider(); + var priority = setPriority ?? modelCacheLockerProvider.GetCacheItemPriority(); + var size = modelCacheLockerProvider.GetCacheEntrySize(); + var waitSeconds = modelCacheLockerProvider.GetModelCacheLockObjectSeconds(); + var cacheLockObject = modelCacheLockerProvider.GetCacheLockObject(cacheKey); var acquire = Monitor.TryEnter(cacheLockObject, TimeSpan.FromSeconds(waitSeconds)); if (!acquire) { diff --git a/src/ShardingCore/EFCores/EFCore5x/ShardingModelSource.cs b/src/ShardingCore/EFCores/EFCore5x/ShardingModelSource.cs index c420d829..8a469218 100644 --- a/src/ShardingCore/EFCores/EFCore5x/ShardingModelSource.cs +++ b/src/ShardingCore/EFCores/EFCore5x/ShardingModelSource.cs @@ -66,9 +66,7 @@ namespace ShardingCore.EFCores ModelDependencies modelDependencies) { - var priority = CacheItemPriority.High; - var size = 200; - var waitSeconds = 3; + CacheItemPriority? setPriority = null; if (context is IShardingTableDbContext shardingTableDbContext) { if (shardingTableDbContext.RouteTail is null) @@ -82,20 +80,19 @@ namespace ShardingCore.EFCores } else if (shardingTableDbContext.RouteTail is ISingleQueryRouteTail singleQueryRouteTail&& singleQueryRouteTail.IsShardingTableQuery()) { - priority = CacheItemPriority.Normal; + setPriority = CacheItemPriority.Normal; } } var cache = Dependencies.MemoryCache; var cacheKey = Dependencies.ModelCacheKeyFactory.Create(context); if (!cache.TryGetValue(cacheKey, out IModel model)) { - if (context is IShardingModelCacheOption shardingModelCacheOption) - { - priority = shardingModelCacheOption.GetModelCachePriority(); - size = shardingModelCacheOption.GetModelCacheEntrySize(); - waitSeconds = shardingModelCacheOption.GetModelCacheLockObjectSeconds(); - } - var cacheLockObject = _shardingRuntimeContext.GetModelCacheLockerProvider().GetCacheLockObject(cacheKey); + var modelCacheLockerProvider = _shardingRuntimeContext.GetModelCacheLockerProvider(); + + var priority = setPriority ?? modelCacheLockerProvider.GetCacheItemPriority(); + var size = modelCacheLockerProvider.GetCacheEntrySize(); + var waitSeconds = modelCacheLockerProvider.GetModelCacheLockObjectSeconds(); + var cacheLockObject = modelCacheLockerProvider.GetCacheLockObject(cacheKey); // Make sure OnModelCreating really only gets called once, since it may not be thread safe. var acquire = Monitor.TryEnter(cacheLockObject, TimeSpan.FromSeconds(waitSeconds)); if (!acquire) diff --git a/src/ShardingCore/EFCores/EFCore6x/ShardingModelSource.cs b/src/ShardingCore/EFCores/EFCore6x/ShardingModelSource.cs index 9623a4a4..47752f55 100644 --- a/src/ShardingCore/EFCores/EFCore6x/ShardingModelSource.cs +++ b/src/ShardingCore/EFCores/EFCore6x/ShardingModelSource.cs @@ -10,6 +10,7 @@ using ShardingCore.Core.VirtualRoutes.TableRoutes.RouteTails.Abstractions; using ShardingCore.Exceptions; using ShardingCore.Sharding.Abstractions; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; @@ -78,9 +79,7 @@ namespace ShardingCore.EFCores ModelCreationDependencies modelCreationDependencies, bool designTime) { - var priority = CacheItemPriority.High; - var size = 200; - var waitSeconds = 3; + CacheItemPriority? setPriority = null; if (context is IShardingTableDbContext shardingTableDbContext) { if (shardingTableDbContext.RouteTail is null) @@ -96,21 +95,19 @@ namespace ShardingCore.EFCores else if (shardingTableDbContext.RouteTail is ISingleQueryRouteTail singleQueryRouteTail && singleQueryRouteTail.IsShardingTableQuery()) { - priority = CacheItemPriority.Normal; + setPriority = CacheItemPriority.Normal; } } var cache = Dependencies.MemoryCache; var cacheKey = Dependencies.ModelCacheKeyFactory.Create(context, designTime); if (!cache.TryGetValue(cacheKey, out IModel model)) { - if (context is IShardingModelCacheOption shardingModelCacheOption) - { - priority = shardingModelCacheOption.GetModelCachePriority(); - size = shardingModelCacheOption.GetModelCacheEntrySize(); - waitSeconds = shardingModelCacheOption.GetModelCacheLockObjectSeconds(); - } + var modelCacheLockerProvider = _shardingRuntimeContext.GetModelCacheLockerProvider(); - var cacheLockObject = _shardingRuntimeContext.GetModelCacheLockerProvider().GetCacheLockObject(cacheKey); + var priority = setPriority ?? modelCacheLockerProvider.GetCacheItemPriority(); + var size = modelCacheLockerProvider.GetCacheEntrySize(); + var waitSeconds = modelCacheLockerProvider.GetModelCacheLockObjectSeconds(); + var cacheLockObject = modelCacheLockerProvider.GetCacheLockObject(cacheKey); // Make sure OnModelCreating really only gets called once, since it may not be thread safe. var acquire = Monitor.TryEnter(cacheLockObject, TimeSpan.FromSeconds(waitSeconds)); if (!acquire) @@ -138,35 +135,6 @@ namespace ShardingCore.EFCores return model; } - - // public IModelCacheKeyFactory GetModelCacheKeyFactory() - // { - // return Dependencies.ModelCacheKeyFactory; - // } - // - // public object GetSyncObject() - // { - // return _syncObject; - // } - - // public void Remove(object key) - // { - // var acquire = Monitor.TryEnter(_syncObject, TimeSpan.FromSeconds(3)); - // if (!acquire) - // { - // throw new ShardingCoreInvalidOperationException("cache model timeout"); - // } - // try - // { - // - // var cache = Dependencies.MemoryCache; - // cache.Remove(key); - // } - // finally - // { - // Monitor.Exit(_syncObject); - // } - // } } } #endif \ No newline at end of file diff --git a/src/ShardingCore/EFCores/EFCore7x/ShardingModelSource.cs b/src/ShardingCore/EFCores/EFCore7x/ShardingModelSource.cs index 32ad5a32..582ccb50 100644 --- a/src/ShardingCore/EFCores/EFCore7x/ShardingModelSource.cs +++ b/src/ShardingCore/EFCores/EFCore7x/ShardingModelSource.cs @@ -1,5 +1,4 @@ - -#if EFCORE7 +#if EFCORE7 using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; @@ -14,12 +13,12 @@ using ShardingCore.Core.RuntimeContexts; namespace ShardingCore.EFCores { - public class ShardingModelSource : ModelSource { private readonly IShardingRuntimeContext _shardingRuntimeContext; - public ShardingModelSource(ModelSourceDependencies dependencies,IShardingRuntimeContext shardingRuntimeContext) : base(dependencies) + public ShardingModelSource(ModelSourceDependencies dependencies, IShardingRuntimeContext shardingRuntimeContext) + : base(dependencies) { _shardingRuntimeContext = shardingRuntimeContext; Check.NotNull(dependencies, nameof(dependencies)); @@ -44,55 +43,60 @@ namespace ShardingCore.EFCores ModelCreationDependencies modelCreationDependencies, bool designTime) { - var priority = CacheItemPriority.High; - var size = 200; - var waitSeconds = 3; + CacheItemPriority? setPriority = null; if (context is IShardingTableDbContext shardingTableDbContext) { if (shardingTableDbContext.RouteTail is null) { - throw new ShardingCoreInvalidOperationException("db context model is inited before RouteTail set value"); + throw new ShardingCoreInvalidOperationException( + "db context model is inited before RouteTail set value"); } + if (shardingTableDbContext.RouteTail is INoCacheRouteTail) { - var noCacheModel = this.CreateModel(context, modelCreationDependencies.ConventionSetBuilder, modelCreationDependencies.ModelDependencies); - noCacheModel = modelCreationDependencies.ModelRuntimeInitializer.Initialize(noCacheModel, designTime, modelCreationDependencies.ValidationLogger); + var noCacheModel = this.CreateModel(context, modelCreationDependencies.ConventionSetBuilder, + modelCreationDependencies.ModelDependencies); + noCacheModel = modelCreationDependencies.ModelRuntimeInitializer.Initialize(noCacheModel, + designTime, modelCreationDependencies.ValidationLogger); return noCacheModel; } - else - if (shardingTableDbContext.RouteTail is ISingleQueryRouteTail singleQueryRouteTail && singleQueryRouteTail.IsShardingTableQuery()) + else if (shardingTableDbContext.RouteTail is ISingleQueryRouteTail singleQueryRouteTail && + singleQueryRouteTail.IsShardingTableQuery()) { - priority = CacheItemPriority.Normal; + setPriority = CacheItemPriority.Normal; } } + var cache = Dependencies.MemoryCache; var cacheKey = Dependencies.ModelCacheKeyFactory.Create(context, designTime); if (!cache.TryGetValue(cacheKey, out IModel model)) { - if (context is IShardingModelCacheOption shardingModelCacheOption) - { - priority = shardingModelCacheOption.GetModelCachePriority(); - size = shardingModelCacheOption.GetModelCacheEntrySize(); - waitSeconds = shardingModelCacheOption.GetModelCacheLockObjectSeconds(); - } - var cacheLockObject = _shardingRuntimeContext.GetModelCacheLockerProvider().GetCacheLockObject(cacheKey); + var modelCacheLockerProvider = _shardingRuntimeContext.GetModelCacheLockerProvider(); + + var priority = setPriority ?? modelCacheLockerProvider.GetCacheItemPriority(); + var size = modelCacheLockerProvider.GetCacheEntrySize(); + var waitSeconds = modelCacheLockerProvider.GetModelCacheLockObjectSeconds(); + var cacheLockObject = modelCacheLockerProvider.GetCacheLockObject(cacheKey); // Make sure OnModelCreating really only gets called once, since it may not be thread safe. var acquire = Monitor.TryEnter(cacheLockObject, TimeSpan.FromSeconds(waitSeconds)); if (!acquire) { throw new ShardingCoreInvalidOperationException("cache model timeout"); } + try { if (!cache.TryGetValue(cacheKey, out model)) { model = CreateModel( - context, modelCreationDependencies.ConventionSetBuilder, modelCreationDependencies.ModelDependencies); + context, modelCreationDependencies.ConventionSetBuilder, + modelCreationDependencies.ModelDependencies); model = modelCreationDependencies.ModelRuntimeInitializer.Initialize( model, designTime, modelCreationDependencies.ValidationLogger); - model = cache.Set(cacheKey, model, new MemoryCacheEntryOptions { Size = size, Priority = priority }); + model = cache.Set(cacheKey, model, + new MemoryCacheEntryOptions { Size = size, Priority = priority }); } } finally diff --git a/src/ShardingCore/EFCores/IShardingModelSource.cs b/src/ShardingCore/EFCores/IShardingModelSource.cs deleted file mode 100644 index 9e197d52..00000000 --- a/src/ShardingCore/EFCores/IShardingModelSource.cs +++ /dev/null @@ -1,17 +0,0 @@ -// using System; -// using System.Collections.Generic; -// using System.Linq; -// using System.Text; -// using System.Threading.Tasks; -// using Microsoft.EntityFrameworkCore.Infrastructure; -// -// namespace ShardingCore.EFCores -// { -// public interface IShardingModelSource -// { -// IModelCacheKeyFactory GetModelCacheKeyFactory(); -// object GetSyncObject(); -// void Remove(object key); -// -// } -// } diff --git a/src/ShardingCore/Extensions/DbContextExtensions/DbContextExtensionShardingCore.cs b/src/ShardingCore/Extensions/DbContextExtensions/DbContextExtensionShardingCore.cs index 6cb88cde..fb7d2c0b 100644 --- a/src/ShardingCore/Extensions/DbContextExtensions/DbContextExtensionShardingCore.cs +++ b/src/ShardingCore/Extensions/DbContextExtensions/DbContextExtensionShardingCore.cs @@ -311,58 +311,6 @@ namespace ShardingCore.Extensions RemoveDbContextRelationModelSaveOnlyThatIsNamedType(dbContext, typeof(T)); } - /// - /// 移除模型缓存 - /// - /// -// public static void RemoveModelCache(this DbContext dbContext) -// { -// #if !EFCORE2 && !EFCORE3 && !EFCORE5 && !EFCORE6 && !EFCORE7 -// throw new NotImplementedException(); -// #endif -// #if EFCORE6 || EFCORE7 -// var shardingModelSource = dbContext.GetService() as IShardingModelSource; -// var modelCacheKeyFactory = shardingModelSource.GetModelCacheKeyFactory(); -// object key1 = modelCacheKeyFactory.Create(dbContext,true); -// shardingModelSource.Remove(key1); -// object key2 = modelCacheKeyFactory.Create(dbContext,false); -// shardingModelSource.Remove(key2); -// #endif -// #if EFCORE5 -// var shardingModelSource = dbContext.GetService() as IShardingModelSource; -// var modelCacheKeyFactory = shardingModelSource.GetModelCacheKeyFactory(); -// object key1 = modelCacheKeyFactory.Create(dbContext); -// shardingModelSource.Remove(key1); -// #endif -// #if EFCORE3 -// -// var shardingModelSource = dbContext.GetService() as IShardingModelSource; -// var modelCacheKeyFactory = shardingModelSource.GetModelCacheKeyFactory(); -// object key1 = modelCacheKeyFactory.Create(dbContext); -// shardingModelSource.Remove(key1); -// #endif -// -// #if EFCORE2 -// -// var shardingModelSource = dbContext.GetService() as IShardingModelSource; -// var modelCacheKeyFactory = shardingModelSource.GetModelCacheKeyFactory(); -// object key1 = modelCacheKeyFactory.Create(dbContext); -// shardingModelSource.Remove(key1); -// #endif -// } - - // /// - // /// 获取模型创建的锁 - // /// - // /// - // /// - // public static object GetModelCacheSyncObject(this DbContext dbContext) - // { - // IShardingModelSource shardingModelSource = dbContext.GetService() as IShardingModelSource; - // return shardingModelSource.GetSyncObject(); - // } - - public static IEnumerable GetPrimaryKeyValues(TEntity entity,IKey primaryKey) where TEntity : class { return primaryKey.Properties.Select(o =>entity.GetPropertyValue(o.Name)); diff --git a/src/ShardingCore/ShardingCore.csproj b/src/ShardingCore/ShardingCore.csproj index 77601ffd..f87b30d7 100644 --- a/src/ShardingCore/ShardingCore.csproj +++ b/src/ShardingCore/ShardingCore.csproj @@ -1,7 +1,7 @@  net6.0 - 7.7.0.7 + 7.7.0.8 true TRACE;DEBUG;EFCORE7; latest diff --git a/src2/ShardingCore2/ShardingCore2.csproj b/src2/ShardingCore2/ShardingCore2.csproj index 5a922d6f..871b16f6 100644 --- a/src2/ShardingCore2/ShardingCore2.csproj +++ b/src2/ShardingCore2/ShardingCore2.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 7.2.0.7 + 7.2.0.8 true TRACE;DEBUG;EFCORE2; 9.0 diff --git a/src3/ShardingCore3/ShardingCore3.csproj b/src3/ShardingCore3/ShardingCore3.csproj index 71d0718d..a62c6f3f 100644 --- a/src3/ShardingCore3/ShardingCore3.csproj +++ b/src3/ShardingCore3/ShardingCore3.csproj @@ -1,7 +1,7 @@ netstandard2.0 - 7.3.0.7 + 7.3.0.8 true TRACE;DEBUG;EFCORE3; 9.0 diff --git a/src5/ShardingCore5/ShardingCore5.csproj b/src5/ShardingCore5/ShardingCore5.csproj index 3d2de865..cfa480b3 100644 --- a/src5/ShardingCore5/ShardingCore5.csproj +++ b/src5/ShardingCore5/ShardingCore5.csproj @@ -2,7 +2,7 @@ netstandard2.1 - 7.5.0.7 + 7.5.0.8 true TRACE;DEBUG;EFCORE5; 9.0 diff --git a/src6/ShardingCore6/ShardingCore6.csproj b/src6/ShardingCore6/ShardingCore6.csproj index c1dd3023..51959357 100644 --- a/src6/ShardingCore6/ShardingCore6.csproj +++ b/src6/ShardingCore6/ShardingCore6.csproj @@ -2,7 +2,7 @@ net6.0 - 7.6.0.7 + 7.6.0.8 true TRACE;DEBUG;EFCORE6; 9.0