/// <summary> /// 从程序集中刷新实体信息(实现了<see cref="IEntity{TKey}"/>接口的实体类) /// </summary> public void Initialize() { IEntityTypeFinder entityTypeFinder = _scopedServiceProvider.GetService <IEntityTypeFinder>(); Type[] entityTypes = entityTypeFinder.FindAll(true); foreach (Type entityType in entityTypes) { if (_entityInfos.Exists(m => m.TypeName == entityType.FullName)) { continue; } TEntityInfo entityInfo = new TEntityInfo(); entityInfo.FromType(entityType); _entityInfos.Add(entityInfo); } SyncToDatabase(_entityInfos); RefreshCache(); }
/// <summary> /// 从程序集中刷新实体信息(实现了<see cref="IEntity{TKey}"/>接口的实体类) /// </summary> public void Initialize() { Type[] entityTypes = _entityTypeFinder.FindAll(true); _logger.LogInformation($"数据实体处理器开始初始化,共找到 {entityTypes.Length} 个实体类"); foreach (Type entityType in entityTypes) { if (_entityInfos.Exists(m => m.TypeName == entityType.FullName)) { continue; } TEntityInfo entityInfo = new TEntityInfo(); entityInfo.FromType(entityType); _entityInfos.Add(entityInfo); } _serviceProvider.ExecuteScopedWork(provider => { SyncToDatabase(provider, _entityInfos); }); RefreshCache(); }
/// <summary> /// 从程序集中刷新实体信息(实现了<see cref="IEntity{TKey}"/>接口的实体类) /// </summary> public void Initialize() { IEntityTypeFinder entityTypeFinder = ServiceLocator.Instance.GetService <IEntityTypeFinder>(); Type[] entityTypes = entityTypeFinder.FindAll(true); foreach (Type entityType in entityTypes) { if (_entityInfos.Exists(m => m.TypeName == entityType.FullName)) { continue; } TEntityInfo entityInfo = new TEntityInfo(); entityInfo.FromType(entityType); _entityInfos.Add(entityInfo); } ServiceLocator.Instance.ExcuteScopedWork(provider => { SyncToDatabase(provider, _entityInfos); }); RefreshCache(); }