Exemplo n.º 1
0
 public override Type GetFieldType(int i)
 {
     return(CrateTypeMap.GetTypeById(_sqlResponse.ColumnTypes[i].Types[0]));
 }
Exemplo n.º 2
0
        private DataTable GenerateSchemaTable()
        {
            // schema table always must be named as "SchemaTable"
            var table = new DataTable("SchemaTable");

            // create table schema columns
            table.Columns.Add(CrateSchemaTableColumns.ColumnName, typeof(string));
            table.Columns.Add(CrateSchemaTableColumns.ColumnOrdinal, typeof(int));
            table.Columns.Add(CrateSchemaTableColumns.ColumnSize, typeof(int));
            table.Columns.Add(CrateSchemaTableColumns.NumericPrecision, typeof(int));
            table.Columns.Add(CrateSchemaTableColumns.NumericScale, typeof(int));
            table.Columns.Add(CrateSchemaTableColumns.DataType, typeof(Type));
            table.Columns.Add(CrateSchemaTableColumns.ProviderType, typeof(int));
            table.Columns.Add(CrateSchemaTableColumns.ProviderSpecificDataType, typeof(DbType));
            table.Columns.Add(CrateSchemaTableColumns.IsLong, typeof(bool));
            table.Columns.Add(CrateSchemaTableColumns.AllowDbNull, typeof(bool));
            table.Columns.Add(CrateSchemaTableColumns.IsReadOnly, typeof(bool));
            table.Columns.Add(CrateSchemaTableColumns.IsRowVersion, typeof(bool));
            table.Columns.Add(CrateSchemaTableColumns.IsUnique, typeof(bool));
            table.Columns.Add(CrateSchemaTableColumns.IsKey, typeof(bool));
            table.Columns.Add(CrateSchemaTableColumns.IsAutoincrement, typeof(bool));
            table.Columns.Add(CrateSchemaTableColumns.BaseSchemaName, typeof(string));
            table.Columns.Add(CrateSchemaTableColumns.BaseCatalogName, typeof(string));
            table.Columns.Add(CrateSchemaTableColumns.BaseTableName, typeof(string));
            table.Columns.Add(CrateSchemaTableColumns.BaseColumnName, typeof(string));
            table.Columns.Add(CrateSchemaTableColumns.DataTypeName, typeof(string));

            // fill schema table
            for (var fieldIndex = 0; fieldIndex < FieldCount; fieldIndex++)
            {
                // get column name
                var columnName = GetName(fieldIndex);

                // get system type
                var systemType       = GetFieldType(fieldIndex);
                var providerType     = CrateTypeMap.GetDbTypeById(_sqlResponse.ColumnTypes[fieldIndex].Types[0]);
                var providerTypeName = GetDataTypeName(fieldIndex);

                table.Rows.Add(
                    columnName,
                    fieldIndex,
                    0,                                             // size
                    0,                                             // precision
                    0,                                             // scale
                    systemType,                                    // system type
                    _sqlResponse.ColumnTypes[fieldIndex].Types[0], // provider type id
                    providerType,                                  // provider type
                    false,                                         // is blob
                    true,                                          // nullable
                    true,                                          // is readonly
                    false,                                         // is row version
                    false,                                         // is unique
                    false,                                         // is key
                    false,                                         // is autoincrement
                    null,                                          // base schema name
                    null,                                          // catalog name
                    null,                                          // base table name
                    columnName,                                    // base column name
                    providerTypeName                               // provider type name
                    );
            }

            return(table);
        }
Exemplo n.º 3
0
 public override string GetDataTypeName(int i)
 {
     return(CrateTypeMap.GetTypeNameById(_sqlResponse.ColumnTypes[i].Types[0]));
 }