public async Task <List <TableDto> > GetSchemaAsync(
            DbProviderType dbProviderType,
            string connectionString,
            string dbName,
            string dbSchema = null)
        {
            Logger.LogInformation($"---- 数据库类型:{dbProviderType.ToString()}, 开始读取. ----");
            var dtoTables = new List <TableDto>();

            try
            {
                _dbProviderManager.TryGet(dbProviderType, out var dbProvider);
                if (null == dbProvider)
                {
                    Logger.LogInformation($"----数据库类型:{dbProviderType.ToString()} 对应的Provider未找到! ----");
                    return(null);
                }

                var tables = await GetSchemaByDbProviderAsync(dbProvider, connectionString, dbName, dbSchema);

                Logger.LogInformation($"---- 数据库类型:{dbProviderType.ToString()}, 结束读取. ----");

                dtoTables = _objectMapper.Map <List <Table>, List <TableDto> >(tables);
                return(dtoTables);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "读取数据库Schema发生异常.");
            }

            return(dtoTables);
        }
Exemple #2
0
        public void Can_Get_Provider(DbProviderType dbProviderType)
        {
            var result = _dbProviderManager.TryGet(dbProviderType, out var dbProvider);

            result.ShouldBeTrue();
            dbProvider.ShouldNotBeNull();
            dbProvider.Name.ShouldBe(dbProviderType.ToString());
            dbProvider.Factory.ShouldNotBeNull();
        }