修复影子属性使用时GetProperty导致的bug,发布6.8.0.1

This commit is contained in:
xuejiaming 2022-10-24 22:17:38 +08:00
parent 2c8b1d0b57
commit 9f26b1947f
29 changed files with 91 additions and 64 deletions

View File

@ -50,7 +50,6 @@ namespace ShardingCore6x
}).AddShardingCore();
var buildServiceProvider = services.BuildServiceProvider();
buildServiceProvider.UseAutoShardingCreate();
buildServiceProvider.UseAutoTryCompensateTable();
ICollection<Order> orders = new LinkedList<Order>();

View File

@ -48,7 +48,6 @@ namespace ShardingCoreBenchmark5x
}).ReplaceService<ITableEnsureManager,SqlServerTableEnsureManager>().EnsureConfig();
var buildServiceProvider = services.BuildServiceProvider();
buildServiceProvider.UseAutoShardingCreate();
buildServiceProvider.UseAutoTryCompensateTable();
ICollection<Order> orders = new LinkedList<Order>();

View File

@ -1,5 +1,8 @@
namespace Sample.AutoCreateIfPresent
using System.ComponentModel.DataAnnotations.Schema;
namespace Sample.AutoCreateIfPresent
{
[Table("aaa")]
public class AreaDevice
{
public string Id { get; set; }

View File

@ -50,7 +50,6 @@ if (app.Environment.IsDevelopment())
// app.UseSwagger();
// app.UseSwaggerUI();
}
app.Services.UseAutoShardingCreate();
app.Services.UseAutoTryCompensateTable();

View File

@ -47,7 +47,6 @@ namespace Sample.BulkConsole
}).ReplaceService<ITableEnsureManager,SqlServerTableEnsureManager>().EnsureConfig();
var serviceProvider = services.BuildServiceProvider();
serviceProvider.UseAutoShardingCreate();
serviceProvider.UseAutoTryCompensateTable();
using (var serviceScope = serviceProvider.CreateScope())
{

View File

@ -181,7 +181,6 @@ namespace Sample.MySql
}
// app.ApplicationServices.UseAutoTryCompensateTable();
// app.ApplicationServices.UseAutoShardingCreate();
// var shardingRuntimeContext = app.ApplicationServices.GetRequiredService<IShardingRuntimeContext>();
// var entityMetadataManager = shardingRuntimeContext.GetEntityMetadataManager();
// var entityMetadata = entityMetadataManager.TryGet<SysUserMod>();

View File

@ -50,7 +50,7 @@ builder.Services.AddShardingDbContext<DefaultDbContext>()
var app = builder.Build();
// Configure the HTTP request pipeline.
app.Services.UseAutoShardingCreate();
// app.Services.UseAutoShardingCreate();
app.Services.UseAutoTryCompensateTable();
app.UseAuthorization();

View File

@ -125,7 +125,6 @@ namespace Sample.SqlServer
var migrator = defaultShardingDbContext.GetService<IMigrator>();
migrator.Migrate("InitialCreate");
}
app.ApplicationServices.UseAutoShardingCreate();
app.ApplicationServices.UseAutoTryCompensateTable();
app.UseRouting();

View File

@ -69,7 +69,7 @@ namespace Sample.SqlServer.UnionAllMerge
{
var tails = tableRouteResults.Select(o => o.ReplaceTables.FirstOrDefault(r => r.EntityType==entityMetadatas[0].EntityType)?.Tail).ToHashSet();
var sqlGenerationHelper = typeof(QuerySqlGenerator).GetTypeFieldValue(this, "_sqlGenerationHelper") as ISqlGenerationHelper;
var sqlGenerationHelper = ObjectExtension.GetTypeFieldValue(typeof(QuerySqlGenerator),this, "_sqlGenerationHelper") as ISqlGenerationHelper;
string newTableName = null;
if (tails.Count == 1)
{
@ -80,7 +80,7 @@ namespace Sample.SqlServer.UnionAllMerge
newTableName = "(" + string.Join(" union all ", tails.Select(tail => $"select * from {sqlGenerationHelper.DelimitIdentifier($"{tableExpression.Name}{entityMetadatas[0].TableSeparator}{tail}", tableExpression.Schema)}")) + ")";
}
var relationalCommandBuilder = typeof(QuerySqlGenerator).GetTypeFieldValue(this, "_relationalCommandBuilder") as IRelationalCommandBuilder;
var relationalCommandBuilder = ObjectExtension.GetTypeFieldValue(typeof(QuerySqlGenerator),this, "_relationalCommandBuilder") as IRelationalCommandBuilder;
relationalCommandBuilder.Append(newTableName).Append(this.AliasSeparator).Append(sqlGenerationHelper.DelimitIdentifier(tableExpression.Alias));
return tableExpression;
}

View File

@ -90,7 +90,6 @@ namespace Sample.SqlServer3x
app.UseDeveloperExceptionPage();
}
app.ApplicationServices.UseAutoShardingCreate();
app.ApplicationServices.UseAutoTryCompensateTable();
app.UseRouting();

View File

@ -13,7 +13,6 @@ namespace Sample.SqlServerShardingAll
{
public static void UseShardingCore(this IApplicationBuilder app)
{
app.ApplicationServices.UseAutoShardingCreate();
app.ApplicationServices.UseAutoTryCompensateTable();
}
public static void InitSeed(this IApplicationBuilder app)

View File

@ -13,7 +13,6 @@ namespace Sample.SqlServerShardingDataSource
{
public static void UseShardingCore(this IApplicationBuilder app)
{
app.ApplicationServices.UseAutoShardingCreate();
app.ApplicationServices.UseAutoTryCompensateTable();
}
public static void InitSeed(this IApplicationBuilder app)

View File

@ -14,7 +14,6 @@ namespace Sample.SqlServerShardingTable
{
public static void UseShardingCore(this IApplicationBuilder app)
{
app.ApplicationServices.UseAutoShardingCreate();
app.ApplicationServices.UseAutoTryCompensateTable();
}
public static void InitSeed(this IApplicationBuilder app)

View File

@ -28,7 +28,7 @@ namespace Samples.AbpSharding
{
public abstract class AbstractShardingAbpZeroDbContext<TTenant, TRole, TUser, TSelf>
: AbpZeroDbContext<TTenant, TRole, TUser, TSelf>,
IShardingDbContext
IShardingDbContext,IShardingTableDbContext
where TTenant : AbpTenant<TUser>
where TRole : AbpRole<TUser>
where TUser : AbpUser<TUser>

View File

@ -15,7 +15,6 @@ namespace Samples.AutoByDate.SqlServer
{
public static IApplicationBuilder UseShardingCore(this IApplicationBuilder app)
{
app.ApplicationServices.UseAutoShardingCreate();
app.ApplicationServices.UseAutoTryCompensateTable();
return app;
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using Microsoft.EntityFrameworkCore.Infrastructure;
using ShardingCore.Extensions;
#if NETCOREAPP2_0
using Microsoft.EntityFrameworkCore.Internal;
@ -37,7 +38,7 @@ namespace ShardingCore.Core.EntityMetadatas
/// <returns></returns>
public EntityMetadataDataSourceBuilder<TEntity> ShardingProperty(string propertyName)
{
var propertyInfo = typeof(TEntity).GetProperty(propertyName);
var propertyInfo = typeof(TEntity).GetUltimateShadowingProperty(propertyName);
_entityMetadata.SetShardingDataSourceProperty(propertyInfo);
return this;
}
@ -49,7 +50,7 @@ namespace ShardingCore.Core.EntityMetadatas
}
public EntityMetadataDataSourceBuilder<TEntity> ShardingExtraProperty(string propertyName)
{
var propertyInfo = typeof(TEntity).GetProperty(propertyName);
var propertyInfo = typeof(TEntity).GetUltimateShadowingProperty(propertyName);
_entityMetadata.AddExtraSharingDataSourceProperty(propertyInfo);
return this;
}

View File

@ -1,6 +1,7 @@
using System;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Infrastructure;
using ShardingCore.Extensions;
#if NETCOREAPP2_0
using Microsoft.EntityFrameworkCore.Internal;
@ -34,7 +35,7 @@ namespace ShardingCore.Core.EntityMetadatas
}
public EntityMetadataTableBuilder<TEntity> ShardingProperty(string propertyName)
{
var propertyInfo = typeof(TEntity).GetProperty(propertyName);
var propertyInfo = typeof(TEntity).GetUltimateShadowingProperty(propertyName);
_entityMetadata.SetShardingTableProperty(propertyInfo);
return this;
}
@ -46,7 +47,7 @@ namespace ShardingCore.Core.EntityMetadatas
}
public EntityMetadataTableBuilder<TEntity> ShardingExtraProperty(string propertyName)
{
var propertyInfo = typeof(TEntity).GetProperty(propertyName);
var propertyInfo = typeof(TEntity).GetUltimateShadowingProperty(propertyName);
_entityMetadata.AddExtraSharingTableProperty(propertyInfo);
return this;
}

View File

@ -19,7 +19,7 @@ namespace ShardingCore.Extensions
public static void SetPropertyValue<T>(this T t, string name, object value)
{
Type type = t.GetType();
PropertyInfo p = type.GetProperty(name);
PropertyInfo p = type.GetUltimateShadowingProperty(name);
if (p == null)
{
throw new Exception($"type:{typeof(T)} not found [{name}] properity ");
@ -56,7 +56,7 @@ namespace ShardingCore.Extensions
if (propertyExpression.Contains("."))
{
String[] childProperties = propertyExpression.Split('.');
property = entityType.GetProperty(childProperties[0]);
property = entityType.GetUltimateShadowingProperty(childProperties[0]);
//propertyAccess = Expression.MakeMemberAccess(parameter, property);
for (int i = 1; i < childProperties.Length; i++)
{
@ -64,13 +64,13 @@ namespace ShardingCore.Extensions
{
throw new ShardingCoreException($"property:[{propertyExpression}] not in type:[{entityType}]");
}
property = property.PropertyType.GetProperty(childProperties[i]);
property = property.PropertyType.GetUltimateShadowingProperty(childProperties[i]);
//propertyAccess = Expression.MakeMemberAccess(propertyAccess, property);
}
}
else
{
property = entityType.GetProperty(propertyExpression);
property = entityType.GetUltimateShadowingProperty(propertyExpression);
//propertyAccess = Expression.MakeMemberAccess(parameter, property);
}

View File

@ -1,5 +1,6 @@
using System;
using System.Reflection;
using ShardingCore.Core;
namespace ShardingCore.Extensions
{
@ -43,7 +44,7 @@ namespace ShardingCore.Extensions
/// <returns></returns>
public static object GetPropertyValue(this object obj, string propertyName)
{
var property = obj.GetType().GetProperty(propertyName, _bindingFlags);
var property = obj.GetType().GetUltimateShadowingProperty(propertyName, _bindingFlags);
if (property != null)
{
return property.GetValue(obj);
@ -62,7 +63,7 @@ namespace ShardingCore.Extensions
/// <returns></returns>
public static object GetTypePropertyValue(this Type type,object obj, string propertyName)
{
var property=type.GetProperty(propertyName, _bindingFlags);
var property=type.GetUltimateShadowingProperty(propertyName, _bindingFlags);
if (property != null)
{
return property.GetValue(obj);
@ -74,7 +75,7 @@ namespace ShardingCore.Extensions
}
public static PropertyInfo GetObjectProperty(this object obj, string propertyName)
{
return obj.GetType().GetProperty(propertyName, _bindingFlags);
return obj.GetType().GetUltimateShadowingProperty(propertyName,_bindingFlags);
}
/// <summary>
/// 类型X是否包含某个属性
@ -84,7 +85,7 @@ namespace ShardingCore.Extensions
/// <returns></returns>
public static bool ContainPropertyName(this Type type, string propertyName)
{
var property = type.GetProperty(propertyName, _bindingFlags);
var property = type.GetUltimateShadowingProperty(propertyName, _bindingFlags);
return property != null;
}
@ -98,6 +99,52 @@ namespace ShardingCore.Extensions
{
return genericType.MakeGenericType(arg0Type, arg1Type);
}
public static PropertyInfo GetUltimateShadowingProperty(this Type type, string name)
{
return type.GetUltimateShadowingProperty(name,_bindingFlags);
}
/// <summary>
/// https://github.com/nunit/nunit/blob/111fc6b5550f33b4fceb6ac8693c5692e99a5747/src/NUnitFramework/framework/Internal/Reflect.cs
/// </summary>
/// <param name="type"></param>
/// <param name="name"></param>
/// <param name="bindingFlags"></param>
/// <returns></returns>
public static PropertyInfo GetUltimateShadowingProperty(this Type type, string name, BindingFlags bindingFlags)
{
Check.NotNull(type, nameof(type));
Check.NotNull(name, nameof(name));
if ((bindingFlags & BindingFlags.DeclaredOnly) != 0)
{
// If you're asking us to search a hierarchy but only want properties declared in the given type,
// you're in the wrong place but okay:
return type.GetProperty(name, bindingFlags);
}
if ((bindingFlags & (BindingFlags.Public | BindingFlags.NonPublic)) == (BindingFlags.Public | BindingFlags.NonPublic))
{
// If we're searching for both public and nonpublic properties, search for only public first
// because chances are if there is a public property, it would be very surprising to detect the private shadowing property.
for (var publicSearchType = type; publicSearchType != null; publicSearchType = publicSearchType.GetTypeInfo().BaseType)
{
var property = publicSearchType.GetProperty(name, (bindingFlags | BindingFlags.DeclaredOnly) & ~BindingFlags.NonPublic);
if (property != null) return property;
}
// There is no public property, so may as well not ask to include them during the second search.
bindingFlags &= ~BindingFlags.Public;
}
for (var searchType = type; searchType != null; searchType = searchType.GetTypeInfo().BaseType)
{
var property = searchType.GetProperty(name, bindingFlags | BindingFlags.DeclaredOnly);
if (property != null) return property;
}
return null;
}
}
}

View File

@ -23,7 +23,7 @@ namespace ShardingCore.Extensions.ShardingPageExtensions
var entityQueryProvider = source.Provider as EntityQueryProvider??throw new ShardingCoreInvalidOperationException($"cant use sharding page that {nameof(IQueryable)} provider not {nameof(EntityQueryProvider)}");
var shardingQueryCompiler = entityQueryProvider.GetFieldValue("_queryCompiler") as ShardingQueryCompiler??throw new ShardingCoreInvalidOperationException($"cant use sharding page that {nameof(EntityQueryProvider)} not contains {nameof(ShardingQueryCompiler)} filed named _queryCompiler");
var shardingQueryCompiler = ObjectExtension.GetFieldValue(entityQueryProvider,"_queryCompiler") as ShardingQueryCompiler??throw new ShardingCoreInvalidOperationException($"cant use sharding page that {nameof(EntityQueryProvider)} not contains {nameof(ShardingQueryCompiler)} filed named _queryCompiler");
var dbContextAvailable = shardingQueryCompiler as IShardingDbContextAvailable;
if (dbContextAvailable == null)
{

View File

@ -31,17 +31,17 @@ namespace ShardingCore.Extensions
if (propertyName.Contains('.'))
{
String[] childProperties = propertyName.Split('.');
property = entityType.GetProperty(childProperties[0]);
property = entityType.GetUltimateShadowingProperty(childProperties[0]);
propertyAccess = Expression.MakeMemberAccess(parameter, property);
for (int i = 1; i < childProperties.Length; i++)
{
property = property.PropertyType.GetProperty(childProperties[i]);
property = property.PropertyType.GetUltimateShadowingProperty(childProperties[i]);
propertyAccess = Expression.MakeMemberAccess(propertyAccess, property);
}
}
else
{
property = entityType.GetProperty(propertyName);
property = entityType.GetUltimateShadowingProperty(propertyName);
propertyAccess = Expression.MakeMemberAccess(parameter, property);
}

View File

@ -70,7 +70,7 @@ namespace ShardingCore.Sharding.Enumerators.AggregateExtensions
.Select(o => {
// property "Field1"
var mi = typeof(TSource).GetProperty(o);
var mi = typeof(TSource).GetUltimateShadowingProperty(o);
// original value "o.Field1"
var xOriginal = Expression.Property(xParameter, mi);
@ -117,7 +117,7 @@ namespace ShardingCore.Sharding.Enumerators.AggregateExtensions
{
if (source == null) throw new ArgumentNullException(nameof(source));
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));
PropertyInfo property = source.ElementType.GetProperty(propertyName);
PropertyInfo property = source.ElementType.GetUltimateShadowingProperty(propertyName);
return source.Count(property);
}
@ -203,7 +203,7 @@ namespace ShardingCore.Sharding.Enumerators.AggregateExtensions
if (source == null) throw new ArgumentNullException(nameof(source));
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));
PropertyInfo property = source.ElementType.GetProperty(propertyName);
PropertyInfo property = source.ElementType.GetUltimateShadowingProperty(propertyName);
return source.SumByProperty(property);
}
/// <summary>
@ -219,7 +219,7 @@ namespace ShardingCore.Sharding.Enumerators.AggregateExtensions
if (source == null) throw new ArgumentNullException(nameof(source));
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));
PropertyInfo property = source.ElementType.GetProperty(propertyName);
PropertyInfo property = source.ElementType.GetUltimateShadowingProperty(propertyName);
return source.SumByProperty<TSelect>(property);
}
//public static object Average(this IQueryable source, string member)
@ -276,7 +276,7 @@ namespace ShardingCore.Sharding.Enumerators.AggregateExtensions
{
if (source == null) throw new ArgumentNullException(nameof(source));
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));
PropertyInfo property = source.ElementType.GetProperty(propertyName);
PropertyInfo property = source.ElementType.GetUltimateShadowingProperty(propertyName);
return source.Max(property);
}
@ -311,7 +311,7 @@ namespace ShardingCore.Sharding.Enumerators.AggregateExtensions
if (source == null) throw new ArgumentNullException(nameof(source));
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));
PropertyInfo property = source.ElementType.GetProperty(propertyName);
PropertyInfo property = source.ElementType.GetUltimateShadowingProperty(propertyName);
return source.Min(property);
}
public static object Min(this IQueryable source, PropertyInfo property)
@ -353,8 +353,8 @@ namespace ShardingCore.Sharding.Enumerators.AggregateExtensions
if (source == null) throw new ArgumentNullException(nameof(source));
if (averagePropertyName == null) throw new ArgumentNullException(nameof(averagePropertyName));
if (countPropertyName == null) throw new ArgumentNullException(nameof(countPropertyName));
var averageProperty = source.ElementType.GetProperty(averagePropertyName);
var countProperty = source.ElementType.GetProperty(countPropertyName);
var averageProperty = source.ElementType.GetUltimateShadowingProperty(averagePropertyName);
var countProperty = source.ElementType.GetUltimateShadowingProperty(countPropertyName);
return source.AverageWithCount(averageProperty, countProperty, resultType);
}
public static object AverageWithCount(this IQueryable source, PropertyInfo averageProperty, PropertyInfo countProperty, Type resultType)
@ -431,8 +431,8 @@ namespace ShardingCore.Sharding.Enumerators.AggregateExtensions
if (source == null) throw new ArgumentNullException(nameof(source));
if (averagePropertyName == null) throw new ArgumentNullException(nameof(averagePropertyName));
if (sumPropertyName == null) throw new ArgumentNullException(nameof(sumPropertyName));
var averageProperty = source.ElementType.GetProperty(averagePropertyName);
var sumProperty = source.ElementType.GetProperty(sumPropertyName);
var averageProperty = source.ElementType.GetUltimateShadowingProperty(averagePropertyName);
var sumProperty = source.ElementType.GetUltimateShadowingProperty(sumPropertyName);
return source.AverageWithSum(averageProperty, sumProperty, resultType);
}
public static object AverageWithSum(this IQueryable source, PropertyInfo averageProperty, PropertyInfo sumProperty, Type resultType)

View File

@ -50,7 +50,7 @@ namespace ShardingCore.Core.Internal.Visitors
}
if (memberExpression.Member.DeclaringType == null)
return null;
var fromProperty = memberExpression.Member.DeclaringType.GetProperty(memberExpression.Member.Name);
var fromProperty = memberExpression.Member.DeclaringType.GetUltimateShadowingProperty(memberExpression.Member.Name);
return fromProperty;
}
@ -68,7 +68,7 @@ namespace ShardingCore.Core.Internal.Visitors
{
var declaringType = memberExpression.Member.DeclaringType;
var memberName = memberExpression.Member.Name;
var propertyInfo = declaringType.GetProperty(memberName);
var propertyInfo = declaringType.GetUltimateShadowingProperty(memberName);
_selectContext.SelectProperties.Add(new SelectOwnerProperty(declaringType,
propertyInfo));
}
@ -83,7 +83,7 @@ namespace ShardingCore.Core.Internal.Visitors
{
var declaringType = node.Members[i].DeclaringType;
var memberName = node.Members[i].Name;
var propertyInfo = declaringType.GetProperty(memberName);
var propertyInfo = declaringType.GetUltimateShadowingProperty(memberName);
if (node.Arguments[i] is MethodCallExpression methodCallExpression)
{
var method = methodCallExpression.Method;

View File

@ -89,7 +89,7 @@ namespace ShardingCore.Core.Internal.Visitors
if (expression == null)
throw new NotSupportedException("sharding order not support ");
List<string> properties = new List<string>();
GetProperty(properties, expression);
GetPropertyInfo(properties, expression);
if (!properties.Any())
throw new NotSupportedException("sharding order only support property expression");
properties.Reverse();
@ -122,7 +122,7 @@ namespace ShardingCore.Core.Internal.Visitors
var declaringType = memberExpression.Member.DeclaringType;
var memberName = memberExpression.Member.Name;
var propertyInfo = declaringType.GetProperty(memberName);
var propertyInfo = declaringType.GetUltimateShadowingProperty(memberName);
_selectContext.SelectProperties.Add(new SelectOwnerProperty(declaringType, propertyInfo));
//memberExpression.Acc
}else if (expression is MemberInitExpression memberInitExpression)
@ -135,7 +135,7 @@ namespace ShardingCore.Core.Internal.Visitors
{
var declaringType = memberBinding.Member.DeclaringType;
var memberName = memberBinding.Member.Name;
var propertyInfo = declaringType.GetProperty(memberName);
var propertyInfo = declaringType.GetUltimateShadowingProperty(memberName);
_selectContext.SelectProperties.Add(new SelectOwnerProperty(declaringType, propertyInfo));
}
}
@ -151,12 +151,12 @@ namespace ShardingCore.Core.Internal.Visitors
return base.VisitMethodCall(node);
}
private void GetProperty(List<string> properties, MemberExpression memberExpression)
private void GetPropertyInfo(List<string> properties, MemberExpression memberExpression)
{
properties.Add(memberExpression.Member.Name);
if (memberExpression.Expression is MemberExpression member)
{
GetProperty(properties, member);
GetPropertyInfo(properties, member);
}
}

View File

@ -269,16 +269,6 @@ namespace ShardingCore
.ReplaceService<IModelCustomizer, ShardingModelCustomizer>();
}
/// <summary>
/// 当前接口可以直接移除掉,定时任务会在shardingcore初始化的时候自动调用
/// </summary>
/// <param name="serviceProvider"></param>
[Obsolete("can remove this method,sharding core auto invoke.")]
public static void UseAutoShardingCreate(this IServiceProvider serviceProvider)
{
}
/// <summary>
/// 自动尝试补偿表
/// </summary>

View File

@ -112,7 +112,6 @@ namespace ShardingCore.Test
public void Configure(IServiceProvider serviceProvider)
{
//启动ShardingCore创建表任务
serviceProvider.UseAutoShardingCreate();
//启动进行表补偿
serviceProvider.UseAutoTryCompensateTable();
// 有一些测试数据要初始化可以放在这里

View File

@ -102,7 +102,6 @@ namespace ShardingCore.Test2x
// 可以添加要用到的方法参数,会自动从注册的服务中获取服务实例,类似于 asp.net core 里 Configure 方法
public void Configure(IServiceProvider serviceProvider)
{
serviceProvider.UseAutoShardingCreate();
serviceProvider.UseAutoTryCompensateTable();
// 有一些测试数据要初始化可以放在这里
InitData(serviceProvider).GetAwaiter().GetResult();

View File

@ -94,7 +94,6 @@ namespace ShardingCore.Test3x
// 可以添加要用到的方法参数,会自动从注册的服务中获取服务实例,类似于 asp.net core 里 Configure 方法
public void Configure(IServiceProvider serviceProvider)
{
serviceProvider.UseAutoShardingCreate();
serviceProvider.UseAutoTryCompensateTable();
// 有一些测试数据要初始化可以放在这里
InitData(serviceProvider).GetAwaiter().GetResult();

View File

@ -105,7 +105,6 @@ namespace ShardingCore.Test5x
// 可以添加要用到的方法参数,会自动从注册的服务中获取服务实例,类似于 asp.net core 里 Configure 方法
public void Configure(IServiceProvider serviceProvider)
{
serviceProvider.UseAutoShardingCreate();
serviceProvider.UseAutoTryCompensateTable();
// 有一些测试数据要初始化可以放在这里