From c2f14e3a76890a500df08c054a7ed436ed78faa5 Mon Sep 17 00:00:00 2001 From: xuejiaming <326308290@qq.com> Date: Thu, 29 Sep 2022 09:06:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=B9.netstandard2.0?= =?UTF-8?q?=E5=92=8C.netstandard2.1=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README-zh.md | 6 +- README.md | 6 +- .../ChangeTrackers/ShardingChangeTracker.cs | 4 +- .../EFCore3x/ScriptMigrationGenerator.cs | 2 +- .../EFCores/EFCore3x/ShardingModelSource.cs | 2 +- .../EFCore5x/ScriptMigrationGenerator.cs | 2 +- .../EFCores/EFCore5x/ShardingModelSource.cs | 2 +- .../ShardingOptionsExtension.cs | 4 +- .../ShardingWrapOptionsExtension.cs | 4 +- .../UnionAllMergeOptionsExtension.cs | 4 +- .../ShardingRelationalTransaction.cs | 4 +- .../EFCores/ShardingDbSetSource.cs | 6 +- .../EFCores/ShardingInternalDbSet.cs | 6 +- src/ShardingCore/EFCores/ShardingMigrator.cs | 10 +- .../ShardingRelationalTransactionFactory.cs | 4 +- .../ShardingRelationalTransactionManager.cs | 2 +- .../Extensions/DbContextExtension.cs | 38 ++--- src/ShardingCore/Extensions/LinqExtension.cs | 2 +- ...AtMostElementStreamMergeAsyncEnumerator.cs | 4 +- .../Visitors/ShardingQueryPrepareVisitor.cs | 6 +- ...rdingEntityFrameworkQueryableExtensions.cs | 2 +- .../DbContextReplaceQueryableVisitor.cs | 4 +- .../Visitors/Querys/QueryEntitiesVisitor.cs | 6 +- src/ShardingCore/ShardingCore.csproj | 158 +++++++++--------- 24 files changed, 144 insertions(+), 144 deletions(-) diff --git a/README-zh.md b/README-zh.md index a08d759c..6c0f5590 100644 --- a/README-zh.md +++ b/README-zh.md @@ -44,9 +44,9 @@ Release | EF Core | .NET | .NET (Core) Release | .NET (Core) --- | --- -[6.x.x.x](https://www.nuget.org/packages/ShardingCore) | 6.0 -[5.x.x.x](https://www.nuget.org/packages/ShardingCore) | 5.0 -[3.x.x.x](https://www.nuget.org/packages/ShardingCore) | netcoreapp3 +[6.x.x.x](https://www.nuget.org/packages/ShardingCore) | net6 +[5.x.x.x](https://www.nuget.org/packages/ShardingCore) | net5 or netstandard2.1 +[3.x.x.x](https://www.nuget.org/packages/ShardingCore) | netcoreapp3 or netstandard2.0 [2.x.x.x](https://www.nuget.org/packages/ShardingCore) | netcoreapp2 diff --git a/README.md b/README.md index 609fd0a6..46c9d267 100644 --- a/README.md +++ b/README.md @@ -43,9 +43,9 @@ Use Condition Compile With NetFramework not Release | .NET (Core) --- | --- -[6.x.x.x](https://www.nuget.org/packages/ShardingCore) | 6.0 -[5.x.x.x](https://www.nuget.org/packages/ShardingCore) | 5.0 -[3.x.x.x](https://www.nuget.org/packages/ShardingCore) | netcoreapp3 +[6.x.x.x](https://www.nuget.org/packages/ShardingCore) | net6 +[5.x.x.x](https://www.nuget.org/packages/ShardingCore) | net5 or netstandard2.1 +[3.x.x.x](https://www.nuget.org/packages/ShardingCore) | netcoreapp3 or netstandard2.0 [2.x.x.x](https://www.nuget.org/packages/ShardingCore) | netcoreapp2 ## Quick start diff --git a/src/ShardingCore/EFCores/ChangeTrackers/ShardingChangeTracker.cs b/src/ShardingCore/EFCores/ChangeTrackers/ShardingChangeTracker.cs index 62dbdba6..0ea4e6a7 100644 --- a/src/ShardingCore/EFCores/ChangeTrackers/ShardingChangeTracker.cs +++ b/src/ShardingCore/EFCores/ChangeTrackers/ShardingChangeTracker.cs @@ -20,7 +20,7 @@ namespace ShardingCore.EFCores.ChangeTrackers _dbContext = context; } -#if !NETCOREAPP2_0 && !NETCOREAPP3_0 && !NET5_0 && !NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 error #endif @@ -122,7 +122,7 @@ namespace ShardingCore.EFCores.ChangeTrackers } #endif -#if !NETCOREAPP2_0 && !NETCOREAPP3_0 +#if !NETCOREAPP2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_0 public override void Clear() { if (_dbContext is IShardingDbContext) diff --git a/src/ShardingCore/EFCores/EFCore3x/ScriptMigrationGenerator.cs b/src/ShardingCore/EFCores/EFCore3x/ScriptMigrationGenerator.cs index ead0c994..72d85261 100644 --- a/src/ShardingCore/EFCores/EFCore3x/ScriptMigrationGenerator.cs +++ b/src/ShardingCore/EFCores/EFCore3x/ScriptMigrationGenerator.cs @@ -1,4 +1,4 @@ -#if NETCOREAPP3_0 +#if NETCOREAPP3_0 || NETSTANDARD2_0 || NETSTANDARD2_0 using Microsoft.EntityFrameworkCore.Migrations; using ShardingCore.Core.RuntimeContexts; diff --git a/src/ShardingCore/EFCores/EFCore3x/ShardingModelSource.cs b/src/ShardingCore/EFCores/EFCore3x/ShardingModelSource.cs index df86c1f0..9fd57935 100644 --- a/src/ShardingCore/EFCores/EFCore3x/ShardingModelSource.cs +++ b/src/ShardingCore/EFCores/EFCore3x/ShardingModelSource.cs @@ -1,4 +1,4 @@ -#if NETCOREAPP3_0 +#if NETCOREAPP3_0 || NETSTANDARD2_0 using System; using System.Collections.Generic; using System.Linq; diff --git a/src/ShardingCore/EFCores/EFCore5x/ScriptMigrationGenerator.cs b/src/ShardingCore/EFCores/EFCore5x/ScriptMigrationGenerator.cs index 1465d9d5..f66d964b 100644 --- a/src/ShardingCore/EFCores/EFCore5x/ScriptMigrationGenerator.cs +++ b/src/ShardingCore/EFCores/EFCore5x/ScriptMigrationGenerator.cs @@ -1,4 +1,4 @@ -#if NET5_0 +#if NET5_0 || NETSTANDARD2_1 using Microsoft.EntityFrameworkCore.Migrations; using ShardingCore.Core.RuntimeContexts; diff --git a/src/ShardingCore/EFCores/EFCore5x/ShardingModelSource.cs b/src/ShardingCore/EFCores/EFCore5x/ShardingModelSource.cs index c304d61b..e42a7bea 100644 --- a/src/ShardingCore/EFCores/EFCore5x/ShardingModelSource.cs +++ b/src/ShardingCore/EFCores/EFCore5x/ShardingModelSource.cs @@ -1,4 +1,4 @@ -#if NET5_0 +#if NET5_0 || NETSTANDARD2_1 using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; diff --git a/src/ShardingCore/EFCores/OptionsExtensions/ShardingOptionsExtension.cs b/src/ShardingCore/EFCores/OptionsExtensions/ShardingOptionsExtension.cs index 97442ae6..80118c88 100644 --- a/src/ShardingCore/EFCores/OptionsExtensions/ShardingOptionsExtension.cs +++ b/src/ShardingCore/EFCores/OptionsExtensions/ShardingOptionsExtension.cs @@ -14,7 +14,7 @@ namespace ShardingCore.EFCores.OptionsExtensions * @Ver: 1.0 * @Email: 326308290@qq.com */ -#if !NETCOREAPP2_0 && !NETCOREAPP3_0 && !NET5_0 && !NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 error #endif @@ -63,7 +63,7 @@ namespace ShardingCore.EFCores.OptionsExtensions } } #endif -#if NETCOREAPP3_0 || NET5_0 +#if NETCOREAPP3_0 || NETSTANDARD2_0 || NET5_0 || NETSTANDARD2_1 public class ShardingOptionsExtension: IDbContextOptionsExtension { public IShardingRuntimeContext ShardingRuntimeContext { get; } diff --git a/src/ShardingCore/EFCores/OptionsExtensions/ShardingWrapOptionsExtension.cs b/src/ShardingCore/EFCores/OptionsExtensions/ShardingWrapOptionsExtension.cs index 1d1e50d6..5cf0a760 100644 --- a/src/ShardingCore/EFCores/OptionsExtensions/ShardingWrapOptionsExtension.cs +++ b/src/ShardingCore/EFCores/OptionsExtensions/ShardingWrapOptionsExtension.cs @@ -15,7 +15,7 @@ namespace ShardingCore.EFCores.OptionsExtensions * @Email: 326308290@qq.com */ -#if !NETCOREAPP2_0 && !NETCOREAPP3_0 && !NET5_0 && !NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 error #endif #if NET6_0 @@ -55,7 +55,7 @@ namespace ShardingCore.EFCores.OptionsExtensions } } #endif -#if NETCOREAPP3_0 || NET5_0 +#if NETCOREAPP3_0 || NETSTANDARD2_0 || NET5_0 || NETSTANDARD2_1 public class ShardingWrapOptionsExtension: IDbContextOptionsExtension { diff --git a/src/ShardingCore/EFCores/OptionsExtensions/UnionAllMergeOptionsExtension.cs b/src/ShardingCore/EFCores/OptionsExtensions/UnionAllMergeOptionsExtension.cs index d58d3bc4..4db6448c 100644 --- a/src/ShardingCore/EFCores/OptionsExtensions/UnionAllMergeOptionsExtension.cs +++ b/src/ShardingCore/EFCores/OptionsExtensions/UnionAllMergeOptionsExtension.cs @@ -14,7 +14,7 @@ namespace ShardingCore.EFCores.OptionsExtensions * @Email: 326308290@qq.com */ -#if !NETCOREAPP2_0 && !NETCOREAPP3_0 && !NET5_0 && !NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 error #endif #if NET6_0 @@ -50,7 +50,7 @@ namespace ShardingCore.EFCores.OptionsExtensions } } #endif -#if NETCOREAPP3_0 || NET5_0 +#if NETCOREAPP3_0 || NETSTANDARD2_0 || NET5_0 || NETSTANDARD2_1 public class UnionAllMergeOptionsExtension: IDbContextOptionsExtension { diff --git a/src/ShardingCore/EFCores/RelationTransactions/ShardingRelationalTransaction.cs b/src/ShardingCore/EFCores/RelationTransactions/ShardingRelationalTransaction.cs index 76c709a2..ca3a7f0d 100644 --- a/src/ShardingCore/EFCores/RelationTransactions/ShardingRelationalTransaction.cs +++ b/src/ShardingCore/EFCores/RelationTransactions/ShardingRelationalTransaction.cs @@ -20,7 +20,7 @@ namespace ShardingCore.EFCores * @Ver: 1.0 * @Email: 326308290@qq.com */ -#if !NETCOREAPP2_0 && !NETCOREAPP3_0 && !NET5_0 && !NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 error #endif public class ShardingRelationalTransaction : RelationalTransaction @@ -34,7 +34,7 @@ namespace ShardingCore.EFCores } #endif -#if NETCOREAPP3_0 || NET5_0 +#if NETCOREAPP3_0 || NETSTANDARD2_0 || NET5_0 || NETSTANDARD2_1 public ShardingRelationalTransaction(IShardingDbContext shardingDbContext, IRelationalConnection connection, DbTransaction transaction, Guid transactionId, IDiagnosticsLogger logger, bool transactionOwned) : base(connection, diff --git a/src/ShardingCore/EFCores/ShardingDbSetSource.cs b/src/ShardingCore/EFCores/ShardingDbSetSource.cs index 230fb018..789ebdcf 100644 --- a/src/ShardingCore/EFCores/ShardingDbSetSource.cs +++ b/src/ShardingCore/EFCores/ShardingDbSetSource.cs @@ -12,10 +12,10 @@ namespace ShardingCore.EFCores * @Date: Saturday, 14 August 2021 10:17:43 * @Email: 326308290@qq.com */ -#if !NETCOREAPP2_0 && !NETCOREAPP3_0 && !NET5_0 && !NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 error #endif -#if NET5_0 || NET6_0 +#if NET5_0 || NETSTANDARD2_1 || NET6_0 public class ShardingDbSetSource : IDbSetSource { @@ -55,7 +55,7 @@ namespace ShardingCore.EFCores => (c, name) => new ShardingInternalDbSet(c, name); } #endif -#if NETCOREAPP3_0 +#if NETCOREAPP3_0 || NETSTANDARD2_0 public class ShardingDbSetSource:IDbSetSource { diff --git a/src/ShardingCore/EFCores/ShardingInternalDbSet.cs b/src/ShardingCore/EFCores/ShardingInternalDbSet.cs index 32d35230..9d66e85b 100644 --- a/src/ShardingCore/EFCores/ShardingInternalDbSet.cs +++ b/src/ShardingCore/EFCores/ShardingInternalDbSet.cs @@ -26,7 +26,7 @@ namespace ShardingCore.EFCores * @Email: 326308290@qq.com */ -#if !NETCOREAPP2_0 && !NETCOREAPP3_0 && !NET5_0 && !NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 error #endif public class ShardingInternalDbSet : InternalDbSet @@ -36,7 +36,7 @@ namespace ShardingCore.EFCores private readonly IShardingRuntimeContext _shardingRuntimeContext; private LocalView? _localView; -#if NET5_0 || NET6_0 +#if NET5_0 || NETSTANDARD2_1 || NET6_0 public ShardingInternalDbSet(DbContext context, string entityTypeName) : base(context, entityTypeName) { @@ -44,7 +44,7 @@ namespace ShardingCore.EFCores _shardingRuntimeContext = context.GetShardingRuntimeContext(); } #endif -#if NETCOREAPP2_0 || NETCOREAPP3_0 +#if NETCOREAPP2_0 || NETCOREAPP3_0 || NETSTANDARD2_0 public ShardingInternalDbSet(DbContext context) : base(context) { _context = (IShardingDbContext)context; diff --git a/src/ShardingCore/EFCores/ShardingMigrator.cs b/src/ShardingCore/EFCores/ShardingMigrator.cs index db3fc6f4..6928d0e1 100644 --- a/src/ShardingCore/EFCores/ShardingMigrator.cs +++ b/src/ShardingCore/EFCores/ShardingMigrator.cs @@ -35,7 +35,7 @@ namespace ShardingCore.EFCores { private readonly IShardingRuntimeContext _shardingRuntimeContext; -#if !NETCOREAPP2_0 && !NETCOREAPP3_0 && !NET5_0 && !NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 error #endif @@ -46,14 +46,14 @@ namespace ShardingCore.EFCores } #endif -#if NET5_0 +#if NET5_0 || NETSTANDARD2_1 public ShardingMigrator(IShardingRuntimeContext shardingRuntimeContext, IMigrationsAssembly migrationsAssembly, IHistoryRepository historyRepository, IDatabaseCreator databaseCreator, IMigrationsSqlGenerator migrationsSqlGenerator, IRawSqlCommandBuilder rawSqlCommandBuilder, IMigrationCommandExecutor migrationCommandExecutor, IRelationalConnection connection, ISqlGenerationHelper sqlGenerationHelper, ICurrentDbContext currentContext, IConventionSetBuilder conventionSetBuilder, IDiagnosticsLogger logger, IDiagnosticsLogger commandLogger, IDatabaseProvider databaseProvider) : base(migrationsAssembly, historyRepository, databaseCreator, migrationsSqlGenerator, rawSqlCommandBuilder, migrationCommandExecutor, connection, sqlGenerationHelper, currentContext, conventionSetBuilder, logger, commandLogger, databaseProvider) { _shardingRuntimeContext = shardingRuntimeContext; } #endif -#if NETCOREAPP3_0 +#if NETCOREAPP3_0 || NETSTANDARD2_0 public ShardingMigrator(IShardingRuntimeContext shardingRuntimeContext, IMigrationsAssembly migrationsAssembly, IHistoryRepository historyRepository, IDatabaseCreator databaseCreator, IMigrationsSqlGenerator migrationsSqlGenerator, IRawSqlCommandBuilder rawSqlCommandBuilder, IMigrationCommandExecutor migrationCommandExecutor, IRelationalConnection connection, ISqlGenerationHelper sqlGenerationHelper, ICurrentDbContext currentContext, IDiagnosticsLogger logger, IDiagnosticsLogger commandLogger, IDatabaseProvider databaseProvider) : base(migrationsAssembly, historyRepository, databaseCreator, migrationsSqlGenerator, rawSqlCommandBuilder, migrationCommandExecutor, connection, sqlGenerationHelper, currentContext, logger, commandLogger, databaseProvider) { _shardingRuntimeContext = shardingRuntimeContext; @@ -81,7 +81,7 @@ namespace ShardingCore.EFCores await DynamicShardingHelper.DynamicMigrateWithDataSourcesAsync(_shardingRuntimeContext, allDataSourceNames, null,cancellationToken); } -#if NET6_0 || NET5_0 +#if NET6_0 || NET5_0 || NETSTANDARD2_1 public override string GenerateScript(string fromMigration = null, string toMigration = null, MigrationsSqlGenerationOptions options = MigrationsSqlGenerationOptions.Default) @@ -89,7 +89,7 @@ namespace ShardingCore.EFCores return new ScriptMigrationGenerator(_shardingRuntimeContext, fromMigration, toMigration, options).GenerateScript(); } #endif -#if NETCOREAPP3_0 || NETCOREAPP2_0 +#if NETCOREAPP3_0 || NETSTANDARD2_0 || NETCOREAPP2_0 public override string GenerateScript(string fromMigration = null, string toMigration = null, bool idempotent = false) { return new ScriptMigrationGenerator(_shardingRuntimeContext, fromMigration, toMigration, idempotent).GenerateScript(); diff --git a/src/ShardingCore/EFCores/ShardingRelationalTransactionFactory.cs b/src/ShardingCore/EFCores/ShardingRelationalTransactionFactory.cs index cce5d38f..d625cae2 100644 --- a/src/ShardingCore/EFCores/ShardingRelationalTransactionFactory.cs +++ b/src/ShardingCore/EFCores/ShardingRelationalTransactionFactory.cs @@ -18,7 +18,7 @@ namespace ShardingCore.EFCores * @Ver: 1.0 * @Email: 326308290@qq.com */ -#if !NETCOREAPP2_0 && !NETCOREAPP3_0 && !NET5_0 && !NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 error #endif #if NET6_0 @@ -38,7 +38,7 @@ namespace ShardingCore.EFCores } } #endif -#if NETCOREAPP3_0 || NET5_0 +#if NETCOREAPP3_0 || NETSTANDARD2_0 || NET5_0 || NETSTANDARD2_1 public class ShardingRelationalTransactionFactory : RelationalTransactionFactory where TShardingDbContext : DbContext, IShardingDbContext { diff --git a/src/ShardingCore/EFCores/ShardingRelationalTransactionManager.cs b/src/ShardingCore/EFCores/ShardingRelationalTransactionManager.cs index b6bcdf31..4b8c5291 100644 --- a/src/ShardingCore/EFCores/ShardingRelationalTransactionManager.cs +++ b/src/ShardingCore/EFCores/ShardingRelationalTransactionManager.cs @@ -112,7 +112,7 @@ namespace ShardingCore.EFCores _shardingDbContext.NotifyShardingTransaction(); return dbContextTransaction; } -#if !NETCOREAPP3_0 +#if !NETCOREAPP3_0 && !NETSTANDARD2_0 public Task CommitTransactionAsync(CancellationToken cancellationToken = new CancellationToken()) { diff --git a/src/ShardingCore/Extensions/DbContextExtension.cs b/src/ShardingCore/Extensions/DbContextExtension.cs index fc74d586..3ebbda1c 100644 --- a/src/ShardingCore/Extensions/DbContextExtension.cs +++ b/src/ShardingCore/Extensions/DbContextExtension.cs @@ -32,14 +32,14 @@ namespace ShardingCore.Extensions /// public static void RemoveDbContextRelationModelThatIsShardingTable(this DbContext dbContext) { -#if !NETCOREAPP2_0&&!NETCOREAPP3_0&&!NET5_0&&!NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 throw new NotImplementedException(); #endif #if NET6_0 var contextModel = dbContext.GetService().Model; ; #endif -#if NETCOREAPP2_0 || NETCOREAPP3_0 || NET5_0 +#if NETCOREAPP2_0 || NETSTANDARD2_0 || NETCOREAPP3_0 || NET5_0 || NETSTANDARD2_1 var contextModel = dbContext.Model as Model; #endif @@ -55,7 +55,7 @@ namespace ShardingCore.Extensions contextModelRelationalModel.Tables.Remove(valueTuples[i]); } #endif -#if NET5_0 +#if NET5_0 || NETSTANDARD2_1 var contextModelRelationalModel = contextModel.RelationalModel as RelationalModel; var valueTuples = contextModelRelationalModel.Tables.Where(o => o.Value.EntityTypeMappings.Any(m => entityMetadataManager.IsShardingTable(m.EntityType.ClrType))).Select(o => o.Key).ToList(); @@ -64,7 +64,7 @@ namespace ShardingCore.Extensions contextModelRelationalModel.Tables.Remove(valueTuples[i]); } #endif -#if NETCOREAPP2_0 || NETCOREAPP3_0 +#if NETCOREAPP2_0 || NETSTANDARD2_0 || NETCOREAPP3_0 var entityTypes = contextModel.GetFieldValue("_entityTypes") as SortedDictionary; var list = entityTypes.Where(o=>entityMetadataManager.IsShardingTable(o.Value.ClrType)).Select(o=>o.Key).ToList(); @@ -109,14 +109,14 @@ namespace ShardingCore.Extensions /// public static void RemoveDbContextAllRelationModelWithoutShardingDataSourceOnly(this DbContext dbContext) { -#if !NETCOREAPP2_0&&!NETCOREAPP3_0&&!NET5_0&&!NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 throw new NotImplementedException(); #endif #if NET6_0 var contextModel = dbContext.GetService().Model; ; #endif -#if NETCOREAPP2_0 || NETCOREAPP3_0 || NET5_0 +#if NETCOREAPP2_0 || NETCOREAPP3_0 || NETSTANDARD2_0 || NET5_0 || NETSTANDARD2_1 var contextModel = dbContext.Model as Model; #endif @@ -132,7 +132,7 @@ namespace ShardingCore.Extensions contextModelRelationalModel.Tables.Remove(valueTuples[i]); } #endif -#if NET5_0 +#if NET5_0 || NETSTANDARD2_1 var contextModelRelationalModel = contextModel.RelationalModel as RelationalModel; var valueTuples = contextModelRelationalModel.Tables.Where(o => o.Value.EntityTypeMappings.Any(m => !entityMetadataManager.IsShardingDataSource(m.EntityType.ClrType)||entityMetadataManager.TryGet(m.EntityType.ClrType)==null)).Select(o => o.Key).ToList(); @@ -141,7 +141,7 @@ namespace ShardingCore.Extensions contextModelRelationalModel.Tables.Remove(valueTuples[i]); } #endif -#if NETCOREAPP2_0 || NETCOREAPP3_0 +#if NETCOREAPP2_0 || NETSTANDARD2_0 || NETCOREAPP3_0 var entityTypes = contextModel.GetFieldValue("_entityTypes") as SortedDictionary; var list = entityTypes.Where(o => !entityMetadataManager.IsShardingDataSource(o.Value.ClrType) || entityMetadataManager.TryGet(o.Value.ClrType) == null).Select(o => o.Key).ToList(); @@ -157,14 +157,14 @@ namespace ShardingCore.Extensions /// public static void RemoveDbContextAllRelationModel(this DbContext dbContext) { -#if !NETCOREAPP2_0&&!NETCOREAPP3_0&&!NET5_0&&!NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 throw new NotImplementedException(); #endif #if NET6_0 var contextModel = dbContext.GetService().Model; ; #endif -#if NETCOREAPP2_0 || NETCOREAPP3_0 || NET5_0 +#if NETCOREAPP2_0 || NETCOREAPP3_0 || NETSTANDARD2_0 || NET5_0 || NETSTANDARD2_1 var contextModel = dbContext.Model as Model; #endif @@ -173,11 +173,11 @@ namespace ShardingCore.Extensions var contextModelRelationalModel = contextModel.GetRelationalModel() as RelationalModel; contextModelRelationalModel.Tables.Clear(); #endif -#if NET5_0 +#if NET5_0 || NETSTANDARD2_1 var contextModelRelationalModel = contextModel.RelationalModel as RelationalModel; contextModelRelationalModel.Tables.Clear(); #endif -#if NETCOREAPP2_0 || NETCOREAPP3_0 +#if NETCOREAPP2_0 || NETCOREAPP3_0 || NETSTANDARD2_0 var entityTypes = contextModel.GetFieldValue("_entityTypes") as SortedDictionary; entityTypes.Clear(); @@ -192,10 +192,10 @@ namespace ShardingCore.Extensions public static void RemoveDbContextRelationModelSaveOnlyThatIsNamedType(this DbContext dbContext, Type shardingType) { -#if !NETCOREAPP2_0 && !NETCOREAPP3_0 && !NET5_0 && !NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 1 #endif -#if NETCOREAPP2_0 ||NETCOREAPP3_0 ||NET5_0 +#if NETCOREAPP2_0 || NETSTANDARD2_0 || NETCOREAPP3_0 ||NET5_0 || NETSTANDARD2_1 var contextModel = dbContext.Model as Model; #endif @@ -220,7 +220,7 @@ namespace ShardingCore.Extensions } #endif -#if NET5_0 +#if NET5_0 || NETSTANDARD2_1 var contextModelRelationalModel = contextModel.RelationalModel as RelationalModel; var entityTypes = contextModel.GetEntityTypes(); @@ -239,7 +239,7 @@ namespace ShardingCore.Extensions contextModelRelationalModel.Tables.Remove(valueTuples[i]); } #endif -#if NETCOREAPP2_0 || NETCOREAPP3_0 +#if NETCOREAPP2_0 || NETSTANDARD2_0 || NETCOREAPP3_0 var entityTypes = contextModel.GetFieldValue("_entityTypes") as SortedDictionary; @@ -270,7 +270,7 @@ namespace ShardingCore.Extensions /// public static void RemoveModelCache(this DbContext dbContext) { -#if !NETCOREAPP2_0&&!NETCOREAPP3_0&&!NET5_0&&!NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 throw new NotImplementedException(); #endif #if NET6_0 @@ -281,13 +281,13 @@ namespace ShardingCore.Extensions object key2 = modelCacheKeyFactory.Create(dbContext,false); shardingModelSource.Remove(key2); #endif -#if NET5_0 +#if NET5_0 || NETSTANDARD2_1 var shardingModelSource = dbContext.GetService() as IShardingModelSource; var modelCacheKeyFactory = shardingModelSource.GetModelCacheKeyFactory(); object key1 = modelCacheKeyFactory.Create(dbContext); shardingModelSource.Remove(key1); #endif -#if NETCOREAPP3_0 +#if NETCOREAPP3_0 || NETSTANDARD2_0 var shardingModelSource = dbContext.GetService() as IShardingModelSource; var modelCacheKeyFactory = shardingModelSource.GetModelCacheKeyFactory(); diff --git a/src/ShardingCore/Extensions/LinqExtension.cs b/src/ShardingCore/Extensions/LinqExtension.cs index eb2478d4..390fcd01 100644 --- a/src/ShardingCore/Extensions/LinqExtension.cs +++ b/src/ShardingCore/Extensions/LinqExtension.cs @@ -16,7 +16,7 @@ namespace ShardingCore.Extensions //public static void ForEach(this IEnumerable source) -#if !NET5_0 +#if !NET5_0 || NETSTANDARD2_1 public static HashSet ToHashSet( this IEnumerable source, IEqualityComparer comparer = null) diff --git a/src/ShardingCore/Sharding/Enumerators/StreamMergeAsync/OneAtMostElementStreamMergeAsyncEnumerator.cs b/src/ShardingCore/Sharding/Enumerators/StreamMergeAsync/OneAtMostElementStreamMergeAsyncEnumerator.cs index d22e0c2a..ce2dd0bf 100644 --- a/src/ShardingCore/Sharding/Enumerators/StreamMergeAsync/OneAtMostElementStreamMergeAsyncEnumerator.cs +++ b/src/ShardingCore/Sharding/Enumerators/StreamMergeAsync/OneAtMostElementStreamMergeAsyncEnumerator.cs @@ -30,7 +30,7 @@ namespace ShardingCore.Sharding.Enumerators.StreamMergeAsync _moveIndex++; return HasElement(); } -#if !NETCOREAPP2_0&&!NETCOREAPP3_0&&!NET5_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NET5_0 && !NETSTANDARD2_1 public ValueTask DisposeAsync() { return ValueTask.CompletedTask; @@ -46,7 +46,7 @@ namespace ShardingCore.Sharding.Enumerators.StreamMergeAsync } #endif -#if NETCOREAPP3_0 || NET5_0 +#if NETCOREAPP3_0 || NETSTANDARD2_0 || NET5_0 || NETSTANDARD2_1 public ValueTask DisposeAsync() { return new ValueTask(); diff --git a/src/ShardingCore/Sharding/Parsers/Visitors/ShardingQueryPrepareVisitor.cs b/src/ShardingCore/Sharding/Parsers/Visitors/ShardingQueryPrepareVisitor.cs index ec5faee8..346f9dc2 100644 --- a/src/ShardingCore/Sharding/Parsers/Visitors/ShardingQueryPrepareVisitor.cs +++ b/src/ShardingCore/Sharding/Parsers/Visitors/ShardingQueryPrepareVisitor.cs @@ -23,7 +23,7 @@ namespace ShardingCore.Sharding.Parsers.Visitors /// Author: xjm /// Created: 2022/5/1 21:43:12 /// Email: 326308290@qq.com -#if !NETCOREAPP2_0 && !NETCOREAPP3_0 && !NET5_0 && !NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 error #endif internal class ShardingQueryPrepareVisitor : ExpressionVisitor @@ -57,7 +57,7 @@ namespace ShardingCore.Sharding.Parsers.Visitors shardingQueryableAsSequenceOptions, shardingEntities, isNoTracking, isIgnoreFilter); } -#if NETCOREAPP2_0 || NETCOREAPP3_0 +#if NETCOREAPP2_0 || NETSTANDARD2_0 || NETCOREAPP3_0 protected override Expression VisitConstant(ConstantExpression node) { if (node.Value is IQueryable queryable) @@ -68,7 +68,7 @@ namespace ShardingCore.Sharding.Parsers.Visitors return base.VisitConstant(node); } #endif -#if NET5_0 || NET6_0 +#if NET5_0 || NETSTANDARD2_1 || NET6_0 protected override Expression VisitExtension(Expression node) { if (node is QueryRootExpression queryRootExpression) diff --git a/src/ShardingCore/Sharding/ShardingEntityFrameworkQueryableExtensions.cs b/src/ShardingCore/Sharding/ShardingEntityFrameworkQueryableExtensions.cs index e6a8899b..20ec4f8a 100644 --- a/src/ShardingCore/Sharding/ShardingEntityFrameworkQueryableExtensions.cs +++ b/src/ShardingCore/Sharding/ShardingEntityFrameworkQueryableExtensions.cs @@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.Internal; -#if NETCOREAPP3_0 +#if NETCOREAPP3_0 || NETSTANDARD2_0 using Microsoft.EntityFrameworkCore.Query.Internal; #endif diff --git a/src/ShardingCore/Sharding/Visitors/DbContextReplaceQueryableVisitor.cs b/src/ShardingCore/Sharding/Visitors/DbContextReplaceQueryableVisitor.cs index 25830d18..390eff0e 100644 --- a/src/ShardingCore/Sharding/Visitors/DbContextReplaceQueryableVisitor.cs +++ b/src/ShardingCore/Sharding/Visitors/DbContextReplaceQueryableVisitor.cs @@ -153,7 +153,7 @@ namespace ShardingCore.Core.Internal.Visitors } } -#if NETCOREAPP2_0 || NETCOREAPP3_0 +#if NETCOREAPP2_0 || NETCOREAPP3_0 || NETSTANDARD2_0 internal class DbContextReplaceQueryableVisitor : DbContextInnerMemberReferenceReplaceQueryableVisitor { private readonly DbContext _dbContext; @@ -193,7 +193,7 @@ namespace ShardingCore.Core.Internal.Visitors } #endif -#if NET5_0 || NET6_0 +#if NET5_0 || NETSTANDARD2_1 || NET6_0 internal class DbContextReplaceQueryableVisitor : DbContextInnerMemberReferenceReplaceQueryableVisitor { private readonly DbContext _dbContext; diff --git a/src/ShardingCore/Sharding/Visitors/Querys/QueryEntitiesVisitor.cs b/src/ShardingCore/Sharding/Visitors/Querys/QueryEntitiesVisitor.cs index dc9b1577..58466f73 100644 --- a/src/ShardingCore/Sharding/Visitors/Querys/QueryEntitiesVisitor.cs +++ b/src/ShardingCore/Sharding/Visitors/Querys/QueryEntitiesVisitor.cs @@ -17,10 +17,10 @@ namespace ShardingCore.Core.Internal.Visitors.Querys * @Date: Saturday, 20 February 2021 11:14:35 * @Email: 326308290@qq.com */ -#if !NETCOREAPP2_0 && !NETCOREAPP3_0 && !NET5_0 && !NET6_0 +#if !NETCOREAPP2_0 && !NETSTANDARD2_0 && !NETCOREAPP3_0 && !NETSTANDARD2_1 && !NET5_0 && !NET6_0 error #endif -#if NETCOREAPP2_0 || NETCOREAPP3_0 +#if NETCOREAPP2_0 || NETCOREAPP3_0 || NETSTANDARD2_0 /// /// 获取分表类型 /// @@ -117,7 +117,7 @@ namespace ShardingCore.Core.Internal.Visitors.Querys } #endif -#if NET5_0 || NET6_0 +#if NET5_0 || NETSTANDARD2_1 || NET6_0 /// /// 获取分表类型 /// diff --git a/src/ShardingCore/ShardingCore.csproj b/src/ShardingCore/ShardingCore.csproj index 6f54e5ce..b1d43e92 100644 --- a/src/ShardingCore/ShardingCore.csproj +++ b/src/ShardingCore/ShardingCore.csproj @@ -1,96 +1,96 @@  - netcoreapp2;netcoreapp3;net5;net6 + netcoreapp2;netcoreapp3;netstandard2.0;netstandard2.1;net5;net6 $(SHARDINGCORE) - true + true TRACE;DEBUG; latest - https://github.com/dotnetcore/sharding-core - logo.png + https://github.com/dotnetcore/sharding-core + logo.png - true - bin\Release\ShardingCore.2x.xml + true + bin\Release\ShardingCore.2x.xml latest - - true - bin\Release\ShardingCore.3x.xml - latest - - - - true - bin\Release\ShardingCore.5x.xml - latest - - - - true - bin\Release\ShardingCore.6x.xml - latest - - - latest + + true + bin\Release\ShardingCore.3x.xml + latest + + + + true + bin\Release\ShardingCore.5x.xml + latest + + + + true + bin\Release\ShardingCore.6x.xml + latest + + + latest + + + true + + + 1701;1702;1591; + + + 1701;1702;1591; + + + 1701;1702;1591; + + + 1701;1702;1591; + + + 1701;1702;1591; + + + 1701;1702;1591; + + + 1701;1702;1591; + + + 1701;1702;1591; - - true - - - 1701;1702;1591; - - - 1701;1702;1591; - - - 1701;1702;1591; - - - 1701;1702;1591; - - - 1701;1702;1591; - - - 1701;1702;1591; - - - 1701;1702;1591; - - - 1701;1702;1591; - - - - - - - + + + + + + - - True - \ - + + True + \ + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - +