Пример #1
0
        private async Task <bool> IsNewCollectionAsync(string dataType)
        {
            var query  = $"SELECT TABLE_NAME FROM {databaseName}.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME = '{dataType}'";
            var reader = await sqlQueryExecutor.ExecuteReaderAsync(query).FirstOrDefaultAsync();

            return(reader == null);
        }
        private async Task <List <SqlColumnInfo> > GetTableSchema(SqlQueryExecutor queryExecutor, string tablePath)
        {
            var databaseName = tablePath.Split('.').First();
            var tableName    = tablePath.Split('.').Last().Replace("[", "").Replace("]", "");
            var query        = "SELECT COLUMN_NAME, IS_NULLABLE, DATA_TYPE "
                               + $"FROM {databaseName}.INFORMATION_SCHEMA.COLUMNS "
                               + $"WHERE TABLE_NAME = '{tableName}'";
            var columns           = queryExecutor.ExecuteReaderAsync(query);
            var columnInformation = new List <SqlColumnInfo>();

            await foreach (var column in columns)
            {
                var columnName = (string)column["COLUMN_NAME"];
                var isNullable = column["IS_NULLABLE"].Equals("YES");
                var dataType   = (string)column["DATA_TYPE"];
                columnInformation.Add(new SqlColumnInfo(columnName, isNullable, dataType));
            }

            return(columnInformation);
        }