diff --git a/src/ShardingCore.MySql/DIExtension.cs b/src/ShardingCore.MySql/DIExtension.cs index 3af20be4..3d3f433d 100644 --- a/src/ShardingCore.MySql/DIExtension.cs +++ b/src/ShardingCore.MySql/DIExtension.cs @@ -28,7 +28,7 @@ namespace ShardingCore.MySql */ public static class DIExtension { - public static IServiceCollection AddShardingSqlServer(this IServiceCollection services, Action configure) + public static IServiceCollection AddShardingMySql(this IServiceCollection services, Action configure) { if (configure == null) throw new ArgumentNullException($"AddScfSqlServerProvider :{nameof(configure)}"); diff --git a/src/ShardingCore/Core/VirtualRoutes/Abstractions/SimpleShardingDateByDayVirtualRoute.cs b/src/ShardingCore/Core/VirtualRoutes/Abstractions/SimpleShardingDateByDayVirtualRoute.cs index 5430efda..7fe238ed 100644 --- a/src/ShardingCore/Core/VirtualRoutes/Abstractions/SimpleShardingDateByDayVirtualRoute.cs +++ b/src/ShardingCore/Core/VirtualRoutes/Abstractions/SimpleShardingDateByDayVirtualRoute.cs @@ -38,27 +38,22 @@ namespace ShardingCore.Core.VirtualRoutes.Abstractions _logger.LogWarning($"没有找到对应的匹配需要进行多表扫描:ShardingOperator:[{shardingOperator}]"); return tail => true; //throw new NotSupportedException(xxxx); - break; case ShardingOperatorEnum.GreaterThan: return tail =>int.Parse(tail) > int.Parse(shardingKey.ConvertLongToTime().ToString("yyyyMMdd")); case ShardingOperatorEnum.GreaterThanOrEqual: //yyyyMMdd return tail =>int.Parse(tail) >= int.Parse(shardingKey.ConvertLongToTime().ToString("yyyyMMdd")); - break; case ShardingOperatorEnum.LessThan: return tail =>int.Parse(tail) < int.Parse(shardingKey.ConvertLongToTime().ToString("yyyyMMdd")); case ShardingOperatorEnum.LessThanOrEqual: //yyyyMMdd return tail =>int.Parse(tail) <= int.Parse(shardingKey.ConvertLongToTime().ToString("yyyyMMdd")); - break; case ShardingOperatorEnum.Equal: //yyyyMMdd return tail =>int.Parse(tail) == int.Parse(shardingKey.ConvertLongToTime().ToString("yyyyMMdd")); - break; case ShardingOperatorEnum.NotEqual: //yyyyMMdd return tail =>int.Parse(tail) != int.Parse(shardingKey.ConvertLongToTime().ToString("yyyyMMdd")); - break; default: throw new ArgumentOutOfRangeException(nameof(shardingOperator), shardingOperator, null); } diff --git a/src/ShardingCore/Core/VirtualRoutes/Abstractions/SimpleShardingDateByWeekVirtualRoute.cs b/src/ShardingCore/Core/VirtualRoutes/Abstractions/SimpleShardingDateByWeekVirtualRoute.cs index b1d69d3f..c7f7155b 100644 --- a/src/ShardingCore/Core/VirtualRoutes/Abstractions/SimpleShardingDateByWeekVirtualRoute.cs +++ b/src/ShardingCore/Core/VirtualRoutes/Abstractions/SimpleShardingDateByWeekVirtualRoute.cs @@ -44,25 +44,20 @@ namespace ShardingCore.Core.VirtualRoutes.Abstractions _logger.LogWarning($"没有找到对应的匹配需要进行多表扫描:ShardingOperator:[{shardingOperator}]"); return tail => true; //throw new NotSupportedException(xxxx); - break; case ShardingOperatorEnum.GreaterThan: case ShardingOperatorEnum.GreaterThanOrEqual: //yyyyMMdd return tail =>String.Compare(tail, GetWeekTableTail(shardingKey), StringComparison.Ordinal) >= 0; - break; case ShardingOperatorEnum.LessThan: case ShardingOperatorEnum.LessThanOrEqual: //yyyyMMdd return tail =>String.Compare(tail, GetWeekTableTail(shardingKey), StringComparison.Ordinal) <= 0; - break; case ShardingOperatorEnum.Equal: //yyyyMMdd return tail =>tail == GetWeekTableTail(shardingKey); - break; case ShardingOperatorEnum.NotEqual: //yyyyMMdd return tail =>tail != GetWeekTableTail(shardingKey); - break; default: throw new ArgumentOutOfRangeException(nameof(shardingOperator), shardingOperator, null); } diff --git a/src/ShardingCore/Exceptions/CreateSqlVirtualTableNotFoundException.cs b/src/ShardingCore/Exceptions/CreateSqlVirtualTableNotFoundException.cs index bfb65e19..fef84b08 100644 --- a/src/ShardingCore/Exceptions/CreateSqlVirtualTableNotFoundException.cs +++ b/src/ShardingCore/Exceptions/CreateSqlVirtualTableNotFoundException.cs @@ -19,11 +19,11 @@ namespace ShardingCore.Exceptions { } - public CreateSqlVirtualTableNotFoundException(string? message) : base(message) + public CreateSqlVirtualTableNotFoundException(string message) : base(message) { } - public CreateSqlVirtualTableNotFoundException(string? message, Exception? innerException) : base(message, innerException) + public CreateSqlVirtualTableNotFoundException(string message, Exception innerException) : base(message, innerException) { } } diff --git a/src/ShardingCore/Exceptions/QueryableRouteNotMatchException.cs b/src/ShardingCore/Exceptions/QueryableRouteNotMatchException.cs index 77ba7248..18bbdbe1 100644 --- a/src/ShardingCore/Exceptions/QueryableRouteNotMatchException.cs +++ b/src/ShardingCore/Exceptions/QueryableRouteNotMatchException.cs @@ -19,11 +19,11 @@ namespace ShardingCore.Exceptions { } - public QueryableRouteNotMatchException(string? message) : base(message) + public QueryableRouteNotMatchException(string message) : base(message) { } - public QueryableRouteNotMatchException(string? message, Exception? innerException) : base(message, innerException) + public QueryableRouteNotMatchException(string message, Exception innerException) : base(message, innerException) { } } diff --git a/src/ShardingCore/Exceptions/ShardingEntityTypeConfiguration404Exception.cs b/src/ShardingCore/Exceptions/ShardingEntityTypeConfiguration404Exception.cs index 8d88dc5d..38c40828 100644 --- a/src/ShardingCore/Exceptions/ShardingEntityTypeConfiguration404Exception.cs +++ b/src/ShardingCore/Exceptions/ShardingEntityTypeConfiguration404Exception.cs @@ -19,11 +19,11 @@ namespace ShardingCore.Exceptions { } - public ShardingEntityTypeConfiguration404Exception(string? message) : base(message) + public ShardingEntityTypeConfiguration404Exception(string message) : base(message) { } - public ShardingEntityTypeConfiguration404Exception(string? message, Exception? innerException) : base(message, innerException) + public ShardingEntityTypeConfiguration404Exception(string message, Exception innerException) : base(message, innerException) { } } diff --git a/src/ShardingCore/Exceptions/ShardingKeyRouteMoreException.cs b/src/ShardingCore/Exceptions/ShardingKeyRouteMoreException.cs index d4b4964c..6cb4b9c1 100644 --- a/src/ShardingCore/Exceptions/ShardingKeyRouteMoreException.cs +++ b/src/ShardingCore/Exceptions/ShardingKeyRouteMoreException.cs @@ -19,11 +19,11 @@ namespace ShardingCore.Exceptions { } - public ShardingKeyRouteMoreException(string? message) : base(message) + public ShardingKeyRouteMoreException(string message) : base(message) { } - public ShardingKeyRouteMoreException(string? message, Exception? innerException) : base(message, innerException) + public ShardingKeyRouteMoreException(string message, Exception innerException) : base(message, innerException) { } } diff --git a/src/ShardingCore/Exceptions/ShardingKeyRouteNotMatchException.cs b/src/ShardingCore/Exceptions/ShardingKeyRouteNotMatchException.cs index 668aa4fa..6eae6e3e 100644 --- a/src/ShardingCore/Exceptions/ShardingKeyRouteNotMatchException.cs +++ b/src/ShardingCore/Exceptions/ShardingKeyRouteNotMatchException.cs @@ -19,11 +19,11 @@ namespace ShardingCore.Exceptions { } - public ShardingKeyRouteNotMatchException(string? message) : base(message) + public ShardingKeyRouteNotMatchException(string message) : base(message) { } - public ShardingKeyRouteNotMatchException(string? message, Exception? innerException) : base(message, innerException) + public ShardingKeyRouteNotMatchException(string message, Exception innerException) : base(message, innerException) { } } diff --git a/src/ShardingCore/Exceptions/ShardingOwnerNotFoundException.cs b/src/ShardingCore/Exceptions/ShardingOwnerNotFoundException.cs index fee31ca3..85e87874 100644 --- a/src/ShardingCore/Exceptions/ShardingOwnerNotFoundException.cs +++ b/src/ShardingCore/Exceptions/ShardingOwnerNotFoundException.cs @@ -19,11 +19,11 @@ namespace ShardingCore.Exceptions { } - public ShardingOwnerNotFoundException(string? message) : base(message) + public ShardingOwnerNotFoundException(string message) : base(message) { } - public ShardingOwnerNotFoundException(string? message, Exception? innerException) : base(message, innerException) + public ShardingOwnerNotFoundException(string message, Exception innerException) : base(message, innerException) { } } diff --git a/src/ShardingCore/Exceptions/ShardingTransactionException.cs b/src/ShardingCore/Exceptions/ShardingTransactionException.cs index c080e4ae..c4612bae 100644 --- a/src/ShardingCore/Exceptions/ShardingTransactionException.cs +++ b/src/ShardingCore/Exceptions/ShardingTransactionException.cs @@ -19,11 +19,11 @@ namespace ShardingCore.Exceptions { } - public ShardingTransactionException(string? message) : base(message) + public ShardingTransactionException(string message) : base(message) { } - public ShardingTransactionException(string? message, Exception? innerException) : base(message, innerException) + public ShardingTransactionException(string message, Exception innerException) : base(message, innerException) { } } diff --git a/src/ShardingCore/Exceptions/VirtualRouteNotFoundException.cs b/src/ShardingCore/Exceptions/VirtualRouteNotFoundException.cs index 1e3a3387..74e81f4b 100644 --- a/src/ShardingCore/Exceptions/VirtualRouteNotFoundException.cs +++ b/src/ShardingCore/Exceptions/VirtualRouteNotFoundException.cs @@ -19,11 +19,11 @@ namespace ShardingCore.Exceptions { } - public VirtualRouteNotFoundException(string? message) : base(message) + public VirtualRouteNotFoundException(string message) : base(message) { } - public VirtualRouteNotFoundException(string? message, Exception? innerException) : base(message, innerException) + public VirtualRouteNotFoundException(string message, Exception innerException) : base(message, innerException) { } } diff --git a/src/ShardingCore/Exceptions/VirtualRouteNotMatchException.cs b/src/ShardingCore/Exceptions/VirtualRouteNotMatchException.cs index 36389d9f..0267e1d5 100644 --- a/src/ShardingCore/Exceptions/VirtualRouteNotMatchException.cs +++ b/src/ShardingCore/Exceptions/VirtualRouteNotMatchException.cs @@ -19,11 +19,11 @@ namespace ShardingCore.Exceptions { } - public VirtualRouteNotMatchException(string? message) : base(message) + public VirtualRouteNotMatchException(string message) : base(message) { } - public VirtualRouteNotMatchException(string? message, Exception? innerException) : base(message, innerException) + public VirtualRouteNotMatchException(string message, Exception innerException) : base(message, innerException) { } } diff --git a/src/ShardingCore/Exceptions/VirtualTableNotFoundException.cs b/src/ShardingCore/Exceptions/VirtualTableNotFoundException.cs index 7f2c97d5..e8939525 100644 --- a/src/ShardingCore/Exceptions/VirtualTableNotFoundException.cs +++ b/src/ShardingCore/Exceptions/VirtualTableNotFoundException.cs @@ -19,11 +19,11 @@ namespace ShardingCore.Exceptions { } - public VirtualTableNotFoundException(string? message) : base(message) + public VirtualTableNotFoundException(string message) : base(message) { } - public VirtualTableNotFoundException(string? message, Exception? innerException) : base(message, innerException) + public VirtualTableNotFoundException(string message, Exception innerException) : base(message, innerException) { } } diff --git a/src/ShardingCore/ShardingBootstrapper.cs b/src/ShardingCore/ShardingBootstrapper.cs index c100e8ba..667f1e1d 100644 --- a/src/ShardingCore/ShardingBootstrapper.cs +++ b/src/ShardingCore/ShardingBootstrapper.cs @@ -85,7 +85,7 @@ namespace ShardingCore { _tableCreator.CreateTable(virtualTable.EntityType, tail); } - catch (Exception e) + catch (Exception) { _logger.LogWarning($"table :{virtualTable.GetOriginalTableName()}{shardingConfig.TailPrefix}{tail} will created"); } diff --git a/test/ShardingCore.Test50/ShardingTest.cs b/test/ShardingCore.Test50/ShardingTest.cs index 6d8edabd..60b531ae 100644 --- a/test/ShardingCore.Test50/ShardingTest.cs +++ b/test/ShardingCore.Test50/ShardingTest.cs @@ -23,7 +23,7 @@ namespace ShardingCore.Test50 } [Fact] - public async Task ToList1() + public async Task ToList_All_Test() { var mods=await _virtualDbContext.Set().ToShardingListAsync(); Assert.Equal(100,mods.Count); @@ -31,7 +31,7 @@ namespace ShardingCore.Test50 Assert.Equal(1000,ranges.Count); } [Fact] - public async Task ToList1_OrderBy() + public async Task ToList1_OrderBy_Test() { var modascs=await _virtualDbContext.Set().OrderBy(o=>o.Age).ToShardingListAsync(); Assert.Equal(100,modascs.Count); @@ -41,7 +41,7 @@ namespace ShardingCore.Test50 Assert.Equal(1,moddescs.Last().Age); } [Fact] - public async Task ToList2() + public async Task ToList_Id_In_Test() { var ids = new[] {"1", "2", "3", "4"}; var sysUserMods=await _virtualDbContext.Set().Where(o=>ids.Contains(o.Id)).ToShardingListAsync(); @@ -53,7 +53,7 @@ namespace ShardingCore.Test50 } } [Fact] - public async Task ToList3() + public async Task ToList_Id_Eq_Test() { var mods=await _virtualDbContext.Set().Where(o=>o.Id=="3").ToShardingListAsync(); Assert.Single(mods); @@ -63,7 +63,7 @@ namespace ShardingCore.Test50 Assert.Equal("3",ranges[0].Id); } [Fact] - public async Task ToList4() + public async Task ToList_Id_Not_Eq_Test() { var mods=await _virtualDbContext.Set().Where(o=>o.Id!="3").ToShardingListAsync(); Assert.Equal(99,mods.Count); @@ -73,7 +73,7 @@ namespace ShardingCore.Test50 Assert.DoesNotContain(ranges,o=>o.Id=="3"); } [Fact] - public async Task ToList5() + public async Task ToList_Name_Eq_Test() { var mods=await _virtualDbContext.Set().Where(o=>o.Name=="name_3").ToShardingListAsync(); Assert.Single(mods); @@ -83,7 +83,7 @@ namespace ShardingCore.Test50 Assert.Equal("3",ranges[0].Id); } [Fact] - public async Task ToList6() + public async Task ToList_Id_Eq_Not_In_Db_Test() { var mods=await _virtualDbContext.Set().Where(o=>o.Id=="1001").ToShardingListAsync(); Assert.Empty(mods); @@ -91,7 +91,7 @@ namespace ShardingCore.Test50 Assert.Empty(ranges); } [Fact] - public async Task ToList7() + public async Task ToList_Name_Eq_Not_In_Db_Test() { var mods=await _virtualDbContext.Set().Where(o=>o.Name=="name_1001").ToShardingListAsync(); Assert.Empty(mods); @@ -99,7 +99,7 @@ namespace ShardingCore.Test50 Assert.Empty(ranges); } [Fact] - public async Task FirstOrDefault1() + public async Task FirstOrDefault_Order_By_Id_Test() { var sysUserMod=await _virtualDbContext.Set().OrderBy(o=>o.Id).ShardingFirstOrDefaultAsync(); Assert.True(sysUserMod!=null&&sysUserMod.Id=="1");