using System; using System.Data.Common; using System.Runtime.CompilerServices; using Npgsql.PostgresTypes; using NpgsqlTypes; namespace Npgsql.Schema; /// /// Provides schema information about a column. /// /// /// Note that this can correspond to a field returned in a query which isn't an actual table column /// /// See https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.getschematable(v=vs.110).aspx /// for information on the meaning of the different fields. /// public class NpgsqlDbColumn : DbColumn { /// /// Initializes a new instance of the class. /// public NpgsqlDbColumn() { PostgresType = UnknownBackendType.Instance; // Not supported in PostgreSQL IsExpression = false; IsAliased = false; IsHidden = false; IsIdentity = false; } internal NpgsqlDbColumn Clone() => Unsafe.As(MemberwiseClone()); #region Standard fields // ReSharper disable once InconsistentNaming /// public new bool? AllowDBNull { get => base.AllowDBNull; protected internal set => base.AllowDBNull = value; } /// public new string BaseCatalogName { get => base.BaseCatalogName!; protected internal set => base.BaseCatalogName = value; } /// public new string? BaseColumnName { get => base.BaseColumnName; protected internal set => base.BaseColumnName = value; } /// public new string? BaseSchemaName { get => base.BaseSchemaName; protected internal set => base.BaseSchemaName = value; } /// public new string BaseServerName { get => base.BaseServerName!; protected internal set => base.BaseServerName = value; } /// public new string? BaseTableName { get => base.BaseTableName; protected internal set => base.BaseTableName = value; } /// public new string ColumnName { get => base.ColumnName; protected internal set => base.ColumnName = value; } /// public new int? ColumnOrdinal { get => base.ColumnOrdinal; protected internal set => base.ColumnOrdinal = value; } /// public new int? ColumnSize { get => base.ColumnSize; protected internal set => base.ColumnSize = value; } /// public new bool? IsAliased { get => base.IsAliased; protected internal set => base.IsAliased = value; } /// public new bool? IsAutoIncrement { get => base.IsAutoIncrement; protected internal set => base.IsAutoIncrement = value; } /// public new bool? IsKey { get => base.IsKey; protected internal set => base.IsKey = value; } /// public new bool? IsLong { get => base.IsLong; protected internal set => base.IsLong = value; } /// public new bool? IsReadOnly { get => base.IsReadOnly; protected internal set => base.IsReadOnly = value; } /// public new bool? IsUnique { get => base.IsUnique; protected internal set => base.IsUnique = value; } /// public new int? NumericPrecision { get => base.NumericPrecision; protected internal set => base.NumericPrecision = value; } /// public new int? NumericScale { get => base.NumericScale; protected internal set => base.NumericScale = value; } /// public new string? UdtAssemblyQualifiedName { get => base.UdtAssemblyQualifiedName; protected internal set => base.UdtAssemblyQualifiedName = value; } /// public new Type? DataType { get => base.DataType; protected internal set => base.DataType = value; } /// public new string DataTypeName { get => base.DataTypeName!; protected internal set => base.DataTypeName = value; } #endregion Standard fields #region Npgsql-specific fields /// /// The describing the type of this column. /// public PostgresType PostgresType { get; internal set; } /// /// The OID of the type of this column in the PostgreSQL pg_type catalog table. /// public uint TypeOID { get; internal set; } /// /// The OID of the PostgreSQL table of this column. /// public uint TableOID { get; internal set; } /// /// The column's position within its table. Note that this is different from , /// which is the column's position within the resultset. /// public short? ColumnAttributeNumber { get; internal set; } /// /// The default SQL expression for this column. /// public string? DefaultValue { get; internal set; } /// /// The value for this column's type. /// public NpgsqlDbType? NpgsqlDbType { get; internal set; } /// public override object? this[string propertyName] => propertyName switch { nameof(PostgresType) => PostgresType, nameof(TypeOID) => TypeOID, nameof(TableOID) => TableOID, nameof(ColumnAttributeNumber) => ColumnAttributeNumber, nameof(DefaultValue) => DefaultValue, nameof(NpgsqlDbType) => NpgsqlDbType, _ => base[propertyName] }; #endregion Npgsql-specific fields }