System.Data.Common.DbDataReader.GetName(int)

Here are the examples of the csharp api class System.Data.Common.DbDataReader.GetName(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

53 Examples 7

1. Example

Project: EDDiscovery
Source File: SQLiteCommandED.cs
View license
public override string GetName(int ordinal) { return InnerReader.GetName(ordinal); }

2. Example

Project: RiotControl
Source File: DatabaseReader.cs
View license
public object Get(string name)
		{
			object output = DataReader[name];
			if (output == null)
			{
				//I think this is bugged in the MySQL library
				for (int i = 0; i < DataReader.FieldCount; i++)
				{
					string currentName = DataReader.GetName(i);
					if (currentName == name)
					{
						output = DataReader[i];
						break;
					}
				}
			}
			Index++;
			return output;
		}

3. Example

Project: Glimpse
Source File: GlimpseDbDataReader.cs
View license
public override string GetName(int ordinal)
        {
            return InnerDataReader.GetName(ordinal);
        }

4. Example

View license
internal string[] GetActiveNames()
            {
                var strArray = new string[DataReader.FieldCount];
                int index = 0;
                int fieldCount = DataReader.FieldCount;
                while (index < fieldCount)
                {
                    strArray[index] = DataReader.GetName(index);
                    index++;
                }
                return strArray;
            }

5. Example

View license
public override string GetName(int i)
            {
                if (names != null)
                {
                    return names[i];
                }
                return reader.GetName(i);
            }

6. Example

Project: ALinq
Source File: AccessDbConnection.cs
View license
public override string GetName(int ordinal)
        {
            return source.GetName(ordinal);
        }

7. Example

Project: ALinq
Source File: DataReader.cs
View license
public override string GetName(int ordinal)
        {
            return source.GetName(ordinal);
        }

8. Example

Project: ALinq
Source File: Connection.cs
View license
public override string GetName(int ordinal)
        {
            return source.GetName(ordinal);
        }

9. Example

Project: ALinq
Source File: Connection.cs
View license
public override string GetName(int ordinal)
        {
            return source.GetName(ordinal);
        }

10. Example

Project: nhibernate-core
Source File: ResultSetWrapper.cs
View license
public override string GetName(int i)
		{
			return rs.GetName(i);
		}

11. Example

View license
public override string GetName(int i)
		{
			return reader.GetName(i);
		}

12. Example

View license
public override string GetName(int i)
		{
			return _reader.GetName(i);
		}

13. Example

Project: nhibernate-core
Source File: CustomLoader.cs
View license
public string GetColumnName(int position)
			{
				return resultSet.GetName(position);
			}

14. Example

Project: NServiceKit
Source File: ProfiledDbDataReader.cs
View license
public override string GetName(int ordinal)
        {
            return _reader.GetName(ordinal);
        }

15. Example

View license
public override string GetName(int ordinal)
        {
            return wrappedReader.GetName(ordinal);
        }

16. Example

View license
public override string GetName(int ordinal)
        {
            return _resultsReader.GetName(ordinal);
        }

17. Example

View license
public override string GetName(int ordinal)
        {
            return this.wrappedDataReader.GetName(ordinal);
        }

18. Example

View license
private int[] GetColumnOrdinals(NamedColumn[] namedColumns)
            {
                DbDataRead/n ..... /n //View Source file for more details /n }

19. Example

View license
public static object Get(DbDataReader rs, IType type, ISessionImplementor session)
		{
			// here is an interesting one: 
			// - MsSql's @@identity returns a Decimal
			// - MySql LAST_IDENITY() returns an Int64 			
			try
			{
				return type.NullSafeGet(rs, rs.GetName(0), session, null);
			}
			catch (Exception e)
			{
				throw new IdentifierGenerationException("could not retrieve identifier value", e);
			}
		}

20. Example

Project: SharpMap
Source File: PostGIS.cs
View license
private FeatureDataTable CreateTableFromReader(DbDataReader reader, int geomIndex)
        {
            var res = new FeatureDataTable { TableName = Table };
            for (var c = 0; c < geomIndex; c++)
            {
                var fieldType = reader.GetFieldType(c);
                if (fieldType == null)
                    throw new Exception("Unable to retrieve field type for column " + c);
                res.Columns.Add(reader.GetName(c), fieldType);
            }
            return res;
        }

21. Example

Project: framework
Source File: FieldReader.cs
View license
internal FieldReaderException CreateFieldReaderException(Exception ex)
        {
            return new FieldReaderException(ex)
            {
                Ordinal = LastOrdinal,
                ColumnName = reader.GetName(LastOrdinal),
                ColumnType = reader.GetFieldType(LastOrdinal),
            };
        }

22. Example

Project: Lidarr
Source File: MappingHelper.cs
View license
public T LoadSimpleValueFromFirstColumn<T>(DbDataReader reader)
        {
            try
            {
                return (T)reader.GetValue(0);
            }
            catch (Exception ex)
            {
                string firstColumnName = reader.GetName(0);
                string msg = string.Format("The DataMapper was unable to create a value of type '{0}' from the first column '{1}'.",
                    typeof(T).Name, firstColumnName);

                throw new DataMappingException(msg, ex);
            }
        }

23. Example

Project: LimeBean
Source File: DatabaseAccess.cs
View license
static IDictionary<string, object> RecordToDict(DbDataReader reader) {
            var count = reader.FieldCount;
            var result = new Dictionary<string, object>();

            for(var i = 0; i < count; i++)
                result[reader.GetName(i)] = StripDbNull(reader.GetValue(i));

            return result;
        }

24. Example

Project: Radarr
Source File: MappingHelper.cs
View license
public T LoadSimpleValueFromFirstColumn<T>(DbDataReader reader)
        {
            try
            {
                return (T)reader.GetValue(0);
            }
            catch (Exception ex)
            {
                string firstColumnName = reader.GetName(0);
                string msg = string.Format("The DataMapper was unable to create a value of type '{0}' from the first column '{1}'.",
                    typeof(T).Name, firstColumnName);

                throw new DataMappingException(msg, ex);
            }
        }

25. Example

Project: SharpMap
Source File: ManagedSpatiaLite.cs
View license
private FeatureDataTable CreateTableFromReader(DbDataReader reader, int geomIndex)
        {
            var res = new FeatureDataTable {TableName = Table};
            for (var c = 0; c < geomIndex; c++)
            {
                var fieldType = reader.GetFieldType(c);
                if (fieldType == null)
                    throw new Exception("Unable to retrieve field type for column " + c);
                res.Columns.Add(DequoteIdentifier(reader.GetName(c)), fieldType);
            }
            return res;
        }

26. Example

Project: SmartStoreNET
Source File: CachingCommand.cs
View license
private static ColumnMetadata[] GetTableMetadata(DbDataReader reader)
		{
			var columnMetadata = new ColumnMetadata[reader.FieldCount];

			for (var i = 0; i < reader.FieldCount; i++)
			{
				columnMetadata[i] = new ColumnMetadata
				{
					Name = reader.GetName(i),
					DataTypeName = reader.GetDataTypeName(i),
					DataType = reader.GetFieldType(i)
				};
			}

			return columnMetadata;
		}

27. Example

Project: Sonarr
Source File: MappingHelper.cs
View license
public T LoadSimpleValueFromFirstColumn<T>(DbDataReader reader)
        {
            try
            {
                return (T)reader.GetValue(0);
            }
            catch (Exception ex)
            {
                string firstColumnName = reader.GetName(0);
                string msg = string.Format("The DataMapper was unable to create a value of type '{0}' from the first column '{1}'.",
                    typeof(T).Name, firstColumnName);

                throw new DataMappingException(msg, ex);
            }
        }

28. Example

Project: RiotControl
Source File: DatabaseReader.cs
View license
public void Dump(string description)
		{
			Console.WriteLine("{0}:\n", description);
			for (int i = 0; i < DataReader.FieldCount; i++)
			{
				object target = DataReader[i];
				Console.WriteLine("[{0} {1}] {2}: {3}", i, DataReader.GetName(i), target.GetType(), target);
			}
		}

29. Example

View license
private static IList<dynamic> GetValues(DbDataReader TempReader)
        {
            Contract.Requires<ArgumentNullException>(TempReader != null, "TempReader");
            var ReturnValue = new List<dynamic>();
            string[] FieldNames = new string[TempReader.FieldCount];
            for (int x = 0; x < TempReader.FieldCount; ++x)
            {
                FieldNames[x] = TempReader.GetName(x);
            }
            while (TempReader.Read())
            {
                var Value = new Dynamo();
                for (int x = 0; x < TempReader.FieldCount; ++x)
                {
                    Value.Add(FieldNames[x], TempReader[x]);
                }
                ReturnValue.Add(Value);
            }
            return ReturnValue;
        }

30. Example

View license
private static IList<dynamic> GetValues(DbDataReader TempReader)
        {
            Contract.Requires<ArgumentNullException>(TempReader != null, "TempReader");
            var ReturnValue = new List<dynamic>();
            string[] FieldNames = new string[TempReader.FieldCount];
            for (int x = 0; x < TempReader.FieldCount; ++x)
            {
                FieldNames[x] = TempReader.GetName(x);
            }
            while (TempReader.Read())
            {
                var Value = new Dynamo();
                for (int x = 0; x < TempReader.FieldCount; ++x)
                {
                    Value.Add(FieldNames[x], TempReader[x]);
                }
                ReturnValue.Add(Value);
            }
            return ReturnValue;
        }

31. Example

View license
public static async Task<object> GetAsync(DbDataReader rs, IType type, ISessionImplementor session, CancellationToken cancellationToken)
		{
			cancellationToken.ThrowIfCancellationRequested();
			// here is an interesting one: 
			// - MsSql's @@identity returns a Decimal
			// - MySql LAST_IDENITY() returns an Int64 			
			try
			{
				return await (type.NullSafeGetAsync(rs, rs.GetName(0), session, null, cancellationToken)).ConfigureAwait(false);
			}
			catch (Exception e)
			{
				throw new IdentifierGenerationException("could not retrieve identifier value", e);
			}
		}

32. Example

Project: linq2db
Source File: DataProviderBase.cs
View license
public virtual Expression GetReaderExpression(MappingSchema mappingSchema, IDataReader reader, int i/n ..... /n //View Source file for more details /n }

33. Example

Project: Kalman.Studio
Source File: MapExt.cs
View license
public static T ToObject<T>(this DbDataReader reader, string readerName, string[] excludeFields, ObjectsChangeTracker changeTracker)
		{
            ///???????????????????readerName???????????????
            if (string.IsNullOrEmpty(readerName))
            {
                var mappingKeyBuilder = new StringBuilder();
                for (int i = 0; i < reader.FieldCount; ++i)
                {
                    mappingKeyBuilder.Append(reader.GetName(i));
                    mappingKeyBuilder.Append('$');
                }
                readerName = mappingKeyBuilder.ToString().ToLower();
            }

			T result = new DataReaderToObjectMapper<T>(readerName, null, excludeFields).MapUsingState(reader, reader);
			if (changeTracker != null)
			{
				changeTracker.RegisterObject(result);
			}
			return result;
		}

34. Example

Project: Kalman.Studio
Source File: MapExt.cs
View license
public static IEnumerable<T> ToObjects<T>(this DbDataReader reader, string readerName, string[] excludeFields, ObjectsChangeTracker changeTracker)
		{
			if (string.IsNullOrEmpty(readerName))
			{
				var mappingKeyBuilder = new StringBuilder();
				for (int i = 0; i < reader.FieldCount; ++i)
				{
					mappingKeyBuilder.Append(reader.GetName(i));
					mappingKeyBuilder.Append('$');
				}
				readerName = mappingKeyBuilder.ToString().ToLower();
			}
			return new DataReaderToObjectMapper<T>(readerName, null, excludeFields).ReadCollection(reader, changeTracker);
		}

35. Example

Project: MimeKit
Source File: X509CertificateDatabase.cs
View license
X509CrlRecord LoadCrlRecord (DbDataReader reader, X509CrlParser parser, ref byte[] buffer)
		{
			var record = new X509CrlRecord ();

			for (int i = 0; i < reader.FieldCount; i++) {
				switch (reader.GetName (i).ToUpperInvariant ()) {
				case "CRL":
					record.Crl = DecodeX509Crl (reader, parser, i, ref buffer);
					break;
				case "THISUPDATE":
					record.ThisUpdate = DateTime.SpecifyKind (reader.GetDateTime (i), DateTimeKind.Utc);
					break;
				case "NEXTUPDATE":
					record.NextUpdate = DateTime.SpecifyKind (reader.GetDateTime (i), DateTimeKind.Utc);
					break;
				case "DELTA":
					record.IsDelta = reader.GetBoolean (i);
					break;
				case "ID":
					record.Id = reader.GetInt32 (i);
					break;
				}
			}

			return record;
		}

36. Example

View license
public override void CreateOrModify_TablesAndFields(string dataTable, DatasetConfig datasetConfig)
 /n ..... /n //View Source file for more details /n }

37. Example

View license
public override void CreateOrModify_TablesAndFields(string dataTable, DatasetConfig datasetConfig)
 /n ..... /n //View Source file for more details /n }

38. Example

Project: nuodb-dotnet
Source File: HelloDB.cs
View license
public void AddNames()
        {
            try
            {
                using (DbCommand command = connection.CreateCommand())
                {
                    command.CommandText = "insert into names (name) values (?),(?),(?),(?),(?),(?),(?),(?),(?),(?),(?),(?),(?),(?),(?)";
                    command.Prepare();

                    /* batch insert a set of names */
                    for (int i = 0; i < 15; i++) 
                    {
                        string name = String.Format("Fred # {0}", i+1);
                        command.Parameters[i].Value = name;
                    }
                    // This is how to retrieve the generated key. Even if it's an update statement, we request the DbReader, that will contain 
                    // only the generated column value
                    using (DbDataReader reader = command.ExecuteReader())
                    {
                        string columnName = reader.GetName(0);
                        while (reader.Read())
                        {
                            Console.Out.WriteLine("New id={0} for column {1}", reader.GetInt64(0), columnName);
                        }
                    }
                }
            }
            catch (NuoDbSqlException e)
            {
                throw e;
            }

        }

39. Example

Project: AntData.ORM
Source File: DataProviderBase.cs
View license
public virtual Expression GetReaderExpression(MappingSchema mappingSchema, IDataReader reader, int i/n ..... /n //View Source file for more details /n }

40. Example

Project: Wexflow
Source File: SqlToXml.cs
View license
private void ConvertToXml(DbConnection connection, DbCommand command)
        {
            connection.Open();
            var reader = command.ExecuteReader();

            if (reader.HasRows)
            {
                var columns = new List<string>();

                for (int i = 0; i < reader.FieldCount; i++)
                {
                    columns.Add(reader.GetName(i));
                }

                string destPath = Path.Combine(Workflow.WorkflowTempFolder,
                                               string.Format("SqlToXml_{0:yyyy-MM-dd-HH-mm-ss-fff}.xml",
                                               DateTime.Now));
                var xdoc = new XDocument();
                var xobjects = new XElement("Records");

                while (reader.Read())
                {
                    var xobject = new XElement("Record");

                    foreach (var column in columns)
                    {
                        xobject.Add(new XElement("Cell"
                            , new XAttribute("column", SecurityElement.Escape(column))
                            , new XAttribute("value", SecurityElement.Escape(reader[column].ToString()))));
                    }
                    xobjects.Add(xobject);
                }
                xdoc.Add(xobjects);
                xdoc.Save(destPath);
                Files.Add(new FileInf(destPath, Id));
                InfoFormat("XML file generated: {0}", destPath);
            }
        }

41. Example

Project: nesper
Source File: PollExecStrategyDBQuery.cs
View license
private IList<EventBean> Execute(DbDriverCommand driverCommand, Object[] lookupValuePerStream)/n ..... /n //View Source file for more details /n }

42. Example

Project: nesper
Source File: PollExecStrategyDBQuery.cs
View license
private IList<EventBean> Execute(DbDriverCommand driverCommand, Object[] lookupValuePerStream)/n ..... /n //View Source file for more details /n }

43. Example

Project: MimeKit
Source File: X509CertificateDatabase.cs
View license
X509CertificateRecord LoadCertificateRecord (DbDataReader reader, X509CertificateParser parser, ref byte[] buffer)
		{
			var record = new X509CertificateRecord ();

			for (int i = 0; i < reader.FieldCount; i++) {
				switch (reader.GetName (i).ToUpperInvariant ()) {
				case "CERTIFICATE":
					record.Certificate = DecodeCertificate (reader, parser, i, ref buffer);
					break;
				case "PRIVATEKEY":
					record.PrivateKey = DecodePrivateKey (reader, i, ref buffer);
					break;
				case "ALGORITHMS":
					record.Algorithms = DecodeEncryptionAlgorithms (reader, i);
					break;
				case "ALGORITHMSUPDATED":
					record.AlgorithmsUpdated = DateTime.SpecifyKind (reader.GetDateTime (i), DateTimeKind.Utc);
					break;
				case "TRUSTED":
					record.IsTrusted = reader.GetBoolean (i);
					break;
				case "ID":
					record.Id = reader.GetInt32 (i);
					break;
				}
			}

			return record;
		}

44. Example

Project: ExcelDna.Utilities
Source File: XLDBWrapper.cs
View license
public static object[,] ToVariant(this DbDataReader reader, string[] properties=null, string[] colhe/n ..... /n //View Source file for more details /n }

45. Example

View license
public IEnumerable<IList<CellData>> Rows()
        {
            var factory = DbProvide/n ..... /n //View Source file for more details /n }

46. Example

View license
public override void CreateOrModify_TablesAndFields(string dataTable, DatasetConfig datasetConfig)
 /n ..... /n //View Source file for more details /n }

47. Example

View license
public override void CreateOrModify_TablesAndFields(string dataTable, DatasetConfig datasetConfig)
 /n ..... /n //View Source file for more details /n }

48. Example

Project: nhibernate-core
Source File: NDataReader.cs
View license
internal static async Task<NResult> CreateAsync(DbDataReader reader, bool isMidstream, CancellationToken cancellationToken)
			{
				cancellationToken.ThrowIfCancellationRequested();
				var result = new NResult
				{
					schemaTable = reader.GetSchemaTable()
				};

				List<object[]> recordsList = new List<object[]>();
				int rowIndex = 0;

				// if we are in the middle of processing the reader then don't bother
				// to move to the next record - just use the current one.
				while (isMidstream || await (reader.ReadAsync(cancellationToken)).ConfigureAwait(false))
				{
					if (rowIndex == 0)
					{
						for (int i = 0; i < reader.FieldCount; i++)
						{
							string fieldName = reader.GetName(i);
							result.fieldNameToIndex[fieldName] = i;
							result.fieldIndexToName.Add(fieldName);
							result.fieldTypes.Add(reader.GetFieldType(i));
							result.fieldDataTypeNames.Add(reader.GetDataTypeName(i));
						}

						result.colCount = reader.FieldCount;
					}

					rowIndex++;

					object[] colValues = new object[reader.FieldCount];
					reader.GetValues(colValues);
					recordsList.Add(colValues);

					// we can go back to reading a reader like normal and don't need
					// to consider where we started from.
					isMidstream = false;
				}

				result.records = recordsList.ToArray();
				return result;
			}

49. Example

Project: nhibernate-core
Source File: NDataReader.cs
View license
internal static NResult Create(DbDataReader reader, bool isMidstream)
			{
				var result = new NResult
				{
					schemaTable = reader.GetSchemaTable()
				};

				List<object[]> recordsList = new List<object[]>();
				int rowIndex = 0;

				// if we are in the middle of processing the reader then don't bother
				// to move to the next record - just use the current one.
				while (isMidstream || reader.Read())
				{
					if (rowIndex == 0)
					{
						for (int i = 0; i < reader.FieldCount; i++)
						{
							string fieldName = reader.GetName(i);
							result.fieldNameToIndex[fieldName] = i;
							result.fieldIndexToName.Add(fieldName);
							result.fieldTypes.Add(reader.GetFieldType(i));
							result.fieldDataTypeNames.Add(reader.GetDataTypeName(i));
						}

						result.colCount = reader.FieldCount;
					}

					rowIndex++;

					object[] colValues = new object[reader.FieldCount];
					reader.GetValues(colValues);
					recordsList.Add(colValues);

					// we can go back to reading a reader like normal and don't need
					// to consider where we started from.
					isMidstream = false;
				}

				result.records = recordsList.ToArray();
				return result;
			}

50. Example

Project: Wexflow
Source File: SqlToCsv.cs
View license
private void ConvertToCsv(DbConnection conn, DbCommand comm)
        {
            conn.Open();
            var reader = comm.ExecuteReader();

            if (reader.HasRows)
            {
                var columns = new List<string>();
                StringBuilder builder = new StringBuilder();

                for (int i = 0; i < reader.FieldCount; i++)
                {
                    columns.Add(reader.GetName(i));
                    builder.Append(reader.GetName(i)).Append(Separator);
                }

                builder.Append("\r\n");
                string destPath = Path.Combine(Workflow.WorkflowTempFolder,
                                               string.Format("SqlToCsv_{0:yyyy-MM-dd-HH-mm-ss-fff}.csv",
                                               DateTime.Now));

                while (reader.Read())
                {
                    foreach (var column in columns)
                    {
                        builder.Append(reader[column]).Append(Separator);
                    }
                    builder.Append("\r\n");
                }

                File.WriteAllText(destPath, builder.ToString());
                Files.Add(new FileInf(destPath, Id));
                InfoFormat("CSV file generated: {0}", destPath);
            }
        }