System.Data.Common.DataAdapter.FillSchema(System.Data.DataTable, System.Data.SchemaType, System.Data.IDataReader)

Here are the examples of the csharp api class System.Data.Common.DataAdapter.FillSchema(System.Data.DataTable, System.Data.SchemaType, System.Data.IDataReader) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

1. Example

Project: DbUtility
Source File: DataTableAdapter.cs
View license
public async Task<DataTable> FillDataTableAsync( DbDataReader dataReader, int startRecord, int maxRecords )
    {

      var dataTable = new DataTable();

      base.FillSchema( dataTable, SchemaType.Source, dataReader );

      var array = new object[dataReader.FieldCount];

      while ( await dataReader.ReadAsync() )
      {
        dataReader.GetValues( array );
        dataTable.LoadDataRow( array, true );
      }

      return dataTable;
    }

2. Example

Project: referencesource
Source File: DbDataAdapter.cs
View license
private object FillSchemaInternal(DataSet dataset, DataTable datatable, SchemaType schemaType, IDbCommand command, string srcTable, CommandBehavior behavior) {
            object dataTables = null;
            bool restoreNullConnection = (null == command.Connection);
            try {
                IDbConnection activeConnection = DbDataAdapter.GetConnection3(this, command, ADP.FillSchema);
                ConnectionState originalState = ConnectionState.Open;

                try {
                    QuietOpen(activeConnection, out originalState);
                    using(IDataReader dataReader = command.ExecuteReader(behavior | CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo)) {
                        if (null != datatable) { // delegate to next set of protected FillSchema methods
                            dataTables = FillSchema(datatable, schemaType, dataReader);
                        }
                        else {
                            dataTables = FillSchema(dataset, schemaType, srcTable, dataReader);
                        }
                    }
                }
                finally {
                    QuietClose(activeConnection, originalState);
                }
            }
            finally {
                if (restoreNullConnection) {
                    command.Transaction = null;
                    command.Connection = null;
                }
            }
            return dataTables;
        }

3. Example

Project: SharpMap
Source File: SpatialDbProvider.cs
View license
protected virtual FeatureDataTable CreateNewTable(bool force)
        {
            if (force || _baseTable == null)
            {
                var fdt = new FeatureDataTable { TableName = Name };

                using (var cn = CreateOpenDbConnection())
                {
                    using (var cmd = cn.CreateCommand())
                    {
                        cmd.CommandText = FeatureColumns.GetSelectClause(From);
                        using (var da = CreateDataAdapter())
                        {
                            da.SelectCommand = cmd;
                            fdt = (FeatureDataTable)da.FillSchema(fdt, SchemaType.Source);
                        }
                    }
                }

                //Remove the geometry column, which is always the last!
                fdt.Columns.RemoveAt(fdt.Columns.Count - 1);
                if (_baseTable == null)
                {
                    _baseTable = fdt;
                    return _baseTable;
                }
                return fdt;
            }
            return _baseTable;
            /*
            var res = new FeatureDataTable(dt);
            var resColumns = res.Columns;
            foreach (var column in dt.Columns)
            {
                resColumns.Add(new DataColumn(column.))
            }
            res.PrimaryKey = new [] {res.Columns[0]};
            return res;
             */
        }

4. Example

Project: referencesource
Source File: Chart.cs
View license
[SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily",
            Justification/n ..... /n //View Source file for more details /n }