예제 #1
0
 public static void SetRowLimitClause(this TOMWrapper.DataSource source, RowLimitClause rowLimitClause)
 {
     source.SetAnnotation(LIMITCLAUSE, $"{(int)rowLimitClause}");
 }
예제 #2
0
 public static void SetRowLimitClause(this Table table, RowLimitClause rowLimitClause)
 {
     table.Partitions[0].DataSource.SetRowLimitClause(rowLimitClause);
 }
예제 #3
0
        private static void DoImport(Pages.ImportMode importMode, Model model, TypedDataSource source, IEnumerable <SchemaNode> schemaNodes, RowLimitClause rowLimitClause, IdentifierQuoting identifierQuoting)
        {
            foreach (var tableSchema in schemaNodes)
            {
                var newTable = model.AddTable(tableSchema.Name);
                if (newTable.Partitions[0] is MPartition)
                {
                    Partition.CreateNew(newTable);
                    newTable.Partitions[0].Delete();
                }
                newTable.Partitions[0].Name  = tableSchema.Name;
                newTable.Partitions[0].Query = tableSchema.GetSql(identifierQuoting, true, source.UseThreePartName);

                if (importMode != Pages.ImportMode.UseTempDs && !(source is SqlDataSource))
                {
                    newTable.Partitions[0].DataSource = model.DataSources[source.TabularDsName];
                    newTable.SetRowLimitClause(rowLimitClause);
                    newTable.SetIdentifierQuoting(identifierQuoting);
                }

                var schemaTable = source.GetSchemaTable(tableSchema, identifierQuoting);
                foreach (DataRow row in schemaTable.Rows)
                {
                    var sourceColumn = row["ColumnName"].ToString();
                    var dataType     =
                        schemaTable.Columns.Contains("DataTypeName") ?
                        row["DataTypeName"].ToString() :
                        (row["DataType"] as Type).Name;
                    var col = newTable.AddDataColumn(
                        sourceColumn, sourceColumn,
                        null,
                        TableMetadata.DataTypeMap(dataType)
                        );
                    col.SourceProviderType = dataType;
                }
                newTable.SetTableSchema(tableSchema);
                newTable.Select();
            }
        }
예제 #4
0
        private static void DoUpdate(Table table, TypedDataSource source, SchemaNode tableSchema, RowLimitClause rowLimitClause, IdentifierQuoting identifierQuoting)
        {
            table.Partitions[0].Name  = tableSchema.Name;
            table.Partitions[0].Query = tableSchema.GetSql(identifierQuoting, true, source.UseThreePartName);
            table.SetTableSchema(tableSchema);

            if (!(source is SqlDataSource))
            {
                table.SetRowLimitClause(rowLimitClause);
                table.SetIdentifierQuoting(identifierQuoting);
            }

            var schemaTable    = source.GetSchemaTable(tableSchema, identifierQuoting);
            var updatedColumns = new HashSet <TOMWrapper.DataColumn>();

            foreach (DataRow row in schemaTable.Rows)
            {
                var sourceColumn = row["ColumnName"].ToString();
                var dataTypeName =
                    schemaTable.Columns.Contains("DataTypeName") ?
                    row["DataTypeName"].ToString() :
                    (row["DataType"] as Type).Name;
                var column = table.DataColumns.FirstOrDefault(c => c.SourceColumn.EqualsI(sourceColumn));
                if (column == null)
                {
                    column = table.AddDataColumn(sourceColumn, sourceColumn);
                }
                column.DataType           = TableMetadata.DataTypeMap(dataTypeName);
                column.SourceProviderType = dataTypeName;

                updatedColumns.Add(column);
            }
            foreach (var col in table.DataColumns.Except(updatedColumns).ToList())
            {
                col.Delete();
            }
        }
예제 #5
0
 protected abstract DataTable InternalGetSampleData(SchemaNode tableOrView, RowLimitClause rowLimitClause, IdentifierQuoting identifierQuoting, out bool isError);
예제 #6
0
 protected override DataTable InternalGetSampleData(SchemaNode tableOrView, RowLimitClause rowLimitClause, IdentifierQuoting identifierQuoting, out bool isError)
 {
     throw new NotImplementedException();
 }