当前位置: 首页>>代码示例>>C#>>正文


C# IDataReader.GetSchemaTable方法代码示例

本文整理汇总了C#中IDataReader.GetSchemaTable方法的典型用法代码示例。如果您正苦于以下问题:C# IDataReader.GetSchemaTable方法的具体用法?C# IDataReader.GetSchemaTable怎么用?C# IDataReader.GetSchemaTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDataReader的用法示例。


在下文中一共展示了IDataReader.GetSchemaTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BulkCopy

		/// <summary>
		/// Bulk copies a set of objects to the server.
		/// </summary>
		/// <param name="connection">The connection to use.</param>
		/// <param name="tableName">The name of the table.</param>
		/// <param name="reader">The reader to read objects from.</param>
		/// <param name="configure">A callback method to configure the bulk copy object.</param>
		/// <param name="options">Options for initializing the bulk copy object.</param>
		/// <param name="transaction">An optional transaction to participate in.</param>
		public override void BulkCopy(IDbConnection connection, string tableName, IDataReader reader, Action<InsightBulkCopy> configure, InsightBulkCopyOptions options, IDbTransaction transaction)
		{
			if (reader == null) throw new ArgumentNullException("reader");
			if (transaction != null)
				throw new ArgumentException("OracleProvider does not support external transactions for bulk copy", "transaction");

			OracleBulkCopyOptions oracleOptions = OracleBulkCopyOptions.Default;
			if (options.HasFlag(InsightBulkCopyOptions.UseInternalTransaction))
				oracleOptions |= OracleBulkCopyOptions.UseInternalTransaction;

			using (var bulk = new OracleBulkCopy((OracleConnection)connection, oracleOptions))
			using (var insightBulk = new OracleInsightBulkCopy(bulk))
			{
				bulk.DestinationTableName = tableName;

				// map the columns by name, in case we skipped a readonly column
				foreach (DataRow row in reader.GetSchemaTable().Rows)
					bulk.ColumnMappings.Add((string)row["ColumnName"], (string)row["ColumnName"]);

				if (configure != null)
					configure(insightBulk);
				bulk.WriteToServer(reader);
			}
		}
开发者ID:EdWeller,项目名称:Insight.Database,代码行数:33,代码来源:OracleInsightDbProvider.cs

示例2: Venue

 public Venue(IDataReader reader)
 {
     _id = (int)reader["VenueID"];
     _name = reader["Name"] as string;
     _profile = reader["Profile"] as string;
     _postalCode = reader["PostalCode"] as string;
     if (!reader.IsDBNull(reader.GetOrdinal("PriceAverage")))
         _priceAverage = float.Parse(reader["PriceAverage"].ToString());
     if (reader.GetSchemaTable().Columns.Contains("RankCount"))
         _rankCount = (int?)reader["RankCount"];
     if (reader.GetSchemaTable().Columns.Contains("RankAverage"))
         _rankAverage = (int?)reader["RankAverage"];
     _createdDate = (DateTime)reader["CreatedDate"];
 }
开发者ID:robgreen,项目名称:nom,代码行数:14,代码来源:Venue.cs

示例3: DetectColumns

        /// <summary>
        /// Generates a column list from a data reader.
        /// </summary>
        /// <param name="dr"></param>
        internal void DetectColumns(IDataReader dr)
        {
            var dt = dr.GetSchemaTable();
            DataFileColumn[] cols;

            if (this.Columns.Count == dt.Rows.Count)
            {
                cols = Columns.ToArray();

                // *** TODO verify type mismatch, or update types
                // keep column name and format
            }
            else
            {
                cols = new DataFileColumn[dt.Rows.Count];

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    cols[i] = new DataFileColumn();
                    TypeUtil.CopyColumnFromSchemaTableRow(cols[i], dt.Rows[i]);
                }
            }

            CreateColumns(cols);
        }
开发者ID:horvatferi,项目名称:graywulf,代码行数:29,代码来源:DataFileBlockBase.cs

示例4: OfflineDataReader

        public OfflineDataReader(IDataReader reader)
        {
            schemaTable = reader.GetSchemaTable();

            //build column index lookup
            int j = 0;
            foreach (DataRow dr in schemaTable.Rows)
            {
                columnLookup[dr["ColumnName"].ToString().ToLower(CultureInfo.InvariantCulture)] = j;
                j++;
            }


            //copy data
            while (reader.Read())
            {
                object[] fields = new object[schemaTable.Rows.Count];
                for (int i = 0; i < fields.Length; i++)
                {
                    fields[i] = reader.GetValue(i);
                }
                records.Add(fields);
            }
            reader.Close();
            reader.Dispose();

            MoveFirst();
        }
开发者ID:Dawn-of-Light,项目名称:Puzzle.NET,代码行数:28,代码来源:OfflineDataReader.cs

示例5: FillTemplateFromReader

        internal static Template FillTemplateFromReader(IDataReader reader)
        {
            var template = new Template();

            if (reader != null && !reader.IsClosed)
            {
                DataTable dt = reader.GetSchemaTable();

                if (dt.Select("ColumnName='" + "CommandId" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("CommandId")))
                        template.TemplateId = reader.GetInt16(reader.GetOrdinal("CommandId"));
                if (dt.Select("ColumnName='" + "Name" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("Name")))
                        template.Name = reader.GetString(reader.GetOrdinal("Name"));
                if (dt.Select("ColumnName='" + "Description" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("Description")))
                        template.Description = reader.GetString(reader.GetOrdinal("Description"));
                if (dt.Select("ColumnName='" + "CannedCommand" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("CannedCommand")))
                        template.CannedCommand = reader.GetByte(reader.GetOrdinal("CannedCommand"));
                if (dt.Select("ColumnName='" + "AppName" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("AppName")))
                        template.AppName = reader.GetString(reader.GetOrdinal("AppName"));
                if (dt.Select("ColumnName='" + "Params" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("Params")))
                        template.Params = reader.GetString(reader.GetOrdinal("Params"));
                if (dt.Select("ColumnName='" + "UseCommandShell" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("UseCommandShell")))
                        template.UseCommandShell = reader.GetByte(reader.GetOrdinal("UseCommandShell"));
                if (dt.Select("ColumnName='" + "TimeoutDurationSecs" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("TimeoutDurationSecs")))
                        template.TimeoutDurationSecs = reader.GetInt16(reader.GetOrdinal("TimeoutDurationSecs"));
                if (dt.Select("ColumnName='" + "UserId" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("UserId")))
                        template.UserId = reader.GetInt16(reader.GetOrdinal("UserId"));
                if (dt.Select("ColumnName='" + "WaitInterval" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("WaitInterval")))
                        template.WaitInterval = reader.GetInt16(reader.GetOrdinal("WaitInterval"));
                if (dt.Select("ColumnName='" + "InvokeCategory" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("InvokeCategory")))
                        template.InvokeCategory = reader.GetString(reader.GetOrdinal("InvokeCategory"));
                if (dt.Select("ColumnName='" + "InvokeItemName" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("InvokeItemName")))
                        template.InvokeItemName = reader.GetString(reader.GetOrdinal("InvokeItemName"));
                if (dt.Select("ColumnName='" + "CommandResultTestPatternText" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("CommandResultTestPatternText")))
                        template.CommandResultTestPatternText = reader.GetString(reader.GetOrdinal("CommandResultTestPatternText"));
                if (dt.Select("ColumnName='" + "CommandResultTestPatternType" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("CommandResultTestPatternType")))
                        template.CommandResultTestPatternType = reader.GetInt16(reader.GetOrdinal("CommandResultTestPatternType"));
                if (dt.Select("ColumnName='" + "CommandMenuGroupId" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("CommandMenuGroupId")))
                        template.CommandMenuGroupId = reader.GetInt16(reader.GetOrdinal("CommandMenuGroupId"));

            }

            return template;
        }
开发者ID:ashishquovantis,项目名称:esqcd,代码行数:58,代码来源:EntityMapper.cs

示例6: GetColumns

        public IList<ProtoDataColumn> GetColumns(
            IDataReader reader, 
            ProtoDataWriterOptions options)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            using (DataTable schema = reader.GetSchemaTable())
            {
                bool schemaSupportsExpressions = schema.Columns.Contains("Expression");

                var columns = new List<ProtoDataColumn>(schema.Rows.Count);
                for (int i = 0; i < schema.Rows.Count; i++)
                {
                    // Assumption: rows in the schema table are always ordered by
                    // Ordinal position, ascending
                    DataRow row = schema.Rows[i];

                    // Skip computed columns unless requested.
                    if (schemaSupportsExpressions)
                    {
                        bool isComputedColumn;

                        if (IsRunningOnMono)
                        {
                            isComputedColumn = Equals(row["Expression"], string.Empty);
                        }
                        else
                        {
                            isComputedColumn = !(row["Expression"] is DBNull);
                        }

                        if (isComputedColumn && !options.IncludeComputedColumns)
                        {
                            continue;
                        }
                    }

                    var col = new ProtoDataColumn
                    {
                        ColumnIndex = i,
                        ProtoDataType = ConvertProtoDataType.FromClrType((Type)row["DataType"]),
                        ColumnName = (string)row["ColumnName"]
                    };

                    columns.Add(col);
                }

                return columns;
            }
        }
开发者ID:julienadam,项目名称:protobuf-net-data,代码行数:58,代码来源:ProtoDataColumnFactory.cs

示例7: DataReaderAdaptor

 public DataReaderAdaptor( IDataReader reader )
 {
     fReader = reader;
     fColumns = new ArrayList();
     foreach (DataRowView row in reader.GetSchemaTable().DefaultView )
     {
         fColumns.Add(row["ColumnName"].ToString().ToUpper());
     }
 }
开发者ID:nsip,项目名称:SifBootCamp-dotNet,代码行数:9,代码来源:DataReaderAdaptor.cs

示例8: GetColumnNames

        internal static IEnumerable<string> GetColumnNames(IDataReader data)
        {
            var columns = new List<string>();
            var sheetSchema = data.GetSchemaTable();
            foreach (DataRow row in sheetSchema.Rows)
                columns.Add(row["ColumnName"].ToString());

            return columns;
        }
开发者ID:allenzhaoxin,项目名称:LinqToExcel,代码行数:9,代码来源:ExcelUtilities.cs

示例9: ObjectHydrationException

 public ObjectHydrationException(string message, Exception innerException, Type type, IDataReader dr) : base(message, innerException)
 {
     _Type = type;
     _Columns = new List<string>();
     foreach (DataRow row in dr.GetSchemaTable().Rows)
     {
         _Columns.Add(row["ColumnName"].ToString());
     }
 }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:9,代码来源:ObjectHydrationException.cs

示例10: initNewTable

 private static Table initNewTable(IDataReader reader){
     Table t;
     t = new Table{Name = reader.GetSchemaTable().TableName};
     for (var i = 0; i < reader.FieldCount; i++){
         var c = new Column{Title = reader.GetName(i), Type = reader.GetFieldType(i)};
         t.Columns.Add(c);
     }
     return t;
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:9,代码来源:Table.cs

示例11: AddColumns

        /// <summary>
        /// 使用 IDataReader 中的结构为指定的表格添加列。
        /// </summary>
        /// <param name="dataTable"></param>
        /// <param name="reader"></param>
        public static void AddColumns(LiteDataTable dataTable, IDataReader reader)
        {
            //columnsCount = reader.FieldCount;

            var schema = reader.GetSchemaTable();
            foreach (DataRow dr in schema.Rows)
            {
                dataTable.Columns.Add(new LiteDataColumn(dr["ColumnName"].ToString(), dr["DataType"].ToString()));
            }
        }
开发者ID:iraychen,项目名称:LCLFramework,代码行数:15,代码来源:LiteDataTableAdapter.cs

示例12: CacheableDataReader

        public CacheableDataReader(IDataReader originalReader)
        {
            if (originalReader == null)
            {
                throw new ArgumentNullException("originalReader");
            }

            cachedData = new DataTable();
            cachedData.Locale = originalReader.GetSchemaTable().Locale;
            cachedData.Load(originalReader);

            Reset();
        }
开发者ID:simonwendel,项目名称:poc-db-cache-interceptor,代码行数:13,代码来源:CacheableDataReader.cs

示例13: ConvertDataReaderToDataSet

        /// <summary>
        /// Converts the data reader to data set.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>DataSet.</returns>
        public static DataSet ConvertDataReaderToDataSet(IDataReader reader)
        {
            DataSet ds = new DataSet();
            DataTable dataTable = new DataTable();

            DataTable schemaTable = reader.GetSchemaTable();
            DataRow row;

            string columnName;
            DataColumn column;
            int count = schemaTable.Rows.Count;

            for (int i = 0; i < count; i++)
            {
                row = schemaTable.Rows[i];
                columnName = (string)row["ColumnName"];

                column = new DataColumn(columnName, (Type)row["DataType"]);
                dataTable.Columns.Add(column);
            }

            ds.Tables.Add(dataTable);

            object[] values = new object[count];

            try
            {
                dataTable.BeginLoadData();
                while (reader.Read())
                {
                    reader.GetValues(values);
                    dataTable.LoadDataRow(values, true);
                }
            }
            finally
            {
                dataTable.EndLoadData();
                reader.Close();
            }

            return ds;
        }
开发者ID:jsheely,项目名称:DotNetNuke-Data-Expose,代码行数:47,代码来源:Utils.cs

示例14: DisconnectedReader

        /// <summary>
        /// Caches a data reader to enable disconnected data access via the IDataReader interface.
        /// </summary>
        /// <param name="reader">The IDataReader to cache.</param>
        public DisconnectedReader(IDataReader reader)
        {
            // Cache field information
            this.fields = new FieldInfo[reader.FieldCount];
            this.ordinals = new Hashtable(StringComparer.OrdinalIgnoreCase);
            for (int index = 0; index < fields.Length; index++)
            {
                FieldInfo field = new FieldInfo();
                field.Name = reader.GetName(index);
                field.Type = reader.GetFieldType(index);
                field.DataTypeName = reader.GetDataTypeName(index);
                fields[index] = field;
                if (!ordinals.Contains(field.Name))
                    ordinals.Add(field.Name, index);
            }

            // Cache schema info
            schema = reader.GetSchemaTable();

            // Cache row data
            rows = new ArrayList();
            while (reader.Read())
            {
                object[] values = new object[fields.Length];
                reader.GetValues(values);
                rows.Add(values);
            }

            // Cache additional results
            if (reader.NextResult())
                nextResult = new DisconnectedReader(reader);

            // Close the reader once all data has been cached
            else
                reader.Dispose();

            // Set the record index before the first record;
            this.recordIndex = -1;

            this.lastIndex = rows.Count - 1;
        }
开发者ID:vc3,项目名称:Amnesia,代码行数:45,代码来源:DisconnectedReader.cs

示例15: BuildObject

 /// <summary>
 /// 请保证数据库字段名和参数名一致.(大小写不计)
 /// 根据属性名和参数名对应的添加参数方法,如果mapping中有和实体类属性相关的参数,自行在外面赋值和设置direction
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="mapping"></param>
 /// <param name="cmd"></param>
 public static void BuildObject(object obj, IDataReader dr)
 {
     if (dr.Read())
     {
         Type t = obj.GetType();
         PropertyInfo[] ps = t.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);
         string name = "";
         DataTable dt = dr.GetSchemaTable();
         int idx;
         object val;
         foreach (PropertyInfo p in ps)//
         {
             name = p.Name;
             if (dt.Select("ColumnName='" + name + "'").Length > 0)
             {
                 val = dr[name];
                 if (DBNull.Value != val)
                     p.SetValue(obj, val, null);
             }
         }
     }
 }
开发者ID:SaintLoong,项目名称:LifeFramwork,代码行数:29,代码来源:SqlHelper.cs


注:本文中的IDataReader.GetSchemaTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。