private static bool IsTypeEquivalent(IDbType columnType, IDbType targetType) { return(columnType.ClrType == targetType.ClrType && (columnType.IsFixedLength == targetType.IsFixedLength || (!columnType.IsFixedLength && targetType.IsFixedLength)) && columnType.MaxLength >= targetType.MaxLength && columnType.DataType == targetType.DataType); }
/// <summary> /// プロパティに列定義をバインドして取得する、バインド済みなら取得のみ行われる /// </summary> /// <param name="propertyName">プロパティ名</param> /// <param name="name">DB上での列名</param> /// <param name="dbType">DB上での型</param> /// <param name="flags">列に対するオプションフラグ</param> /// <param name="source">列を生成する基となった式</param> /// <returns>列定義</returns> public Column BindColumn(string propertyName, string name, IDbType dbType, ColumnFlags flags = 0, ElementCode source = null) { var column = this.ColumnMap.TryGetByPropertyName(propertyName); if (column == null) { this.ColumnMap.Add(column = new Column(this.Owner.Environment, this.Columns, typeof(TColumns).GetProperty(propertyName), this, name, dbType, flags, source)); } return(column); }
public bool TypeEqualsTo(IDbType type) { PgDbType pdt = type as PgDbType; if (pdt == null) { return(false); } return(this.DbType == pdt.DbType); }
/// <summary> /// Initializes a new instance of the <see cref="DatabaseComputedColumn"/> class. /// </summary> /// <param name="columnName">The name of the column. Only the local name is kept.</param> /// <param name="type">The column data type.</param> /// <param name="isNullable">Whether the column can hold <c>null</c> values.</param> /// <param name="defaultValue">The default value expression, if available.</param> /// <param name="definition">The computed column definition, if available.</param> /// <exception cref="ArgumentNullException"><paramref name="columnName"/> or <paramref name="type"/> is <c>null</c></exception> public DatabaseComputedColumn( Identifier columnName, IDbType type, bool isNullable, Option <string> defaultValue, Option <string> definition ) : base(columnName, type, isNullable, defaultValue, Option <IAutoIncrement> .None) { Definition = definition; }
/// <summary> /// Initializes a new instance of the <see cref="OracleDatabaseColumn"/> class. /// </summary> /// <param name="columnName">A column name.</param> /// <param name="type">A column type.</param> /// <param name="isNullable">If set to <c>true</c> the column is nullable.</param> /// <param name="defaultValue">The default value.</param> /// <exception cref="ArgumentNullException"><paramref name="columnName"/> or <paramref name="type"/> is <c>null</c>.</exception> public OracleDatabaseColumn(Identifier columnName, IDbType type, bool isNullable, Option <string> defaultValue) { if (columnName == null) { throw new ArgumentNullException(nameof(columnName)); } Name = columnName.LocalName; Type = type ?? throw new ArgumentNullException(nameof(type)); IsNullable = isNullable; DefaultValue = defaultValue; }
/// <summary> /// Gets the data type that most closely matches the provided data type. /// </summary> /// <param name="otherType">An data type to compare with.</param> /// <returns>The closest matching column data type.</returns> /// <exception cref="ArgumentNullException"><paramref name="otherType"/> is <c>null</c>.</exception> public IDbType GetComparableColumnType(IDbType otherType) { if (otherType == null) { throw new ArgumentNullException(nameof(otherType)); } // only interested in these two bits of information var typeMetadata = new ColumnTypeMetadata { Collation = otherType.Collation, DataType = otherType.DataType }; return(CreateColumnType(typeMetadata)); }
/// <summary> /// Gets the data type that most closely matches the provided data type. /// </summary> /// <param name="otherType">An data type to compare with.</param> /// <returns>The closest matching column data type.</returns> /// <exception cref="ArgumentNullException"><paramref name="otherType"/> is <c>null</c>.</exception> public IDbType GetComparableColumnType(IDbType otherType) { if (otherType == null) { throw new ArgumentNullException(nameof(otherType)); } var typeMetadata = new ColumnTypeMetadata { ClrType = null, // ignoring so we get the default type provided Collation = otherType.Collation, DataType = otherType.DataType, IsFixedLength = otherType.IsFixedLength, MaxLength = otherType.MaxLength, NumericPrecision = otherType.NumericPrecision, TypeName = null // ignoring so we get a default name generated }; return(CreateColumnType(typeMetadata)); }
public Column BindColumn(string propertyName, string name, IDbType dbType, ColumnFlags flags = 0, ElementCode source = null) { return(null); }
/// <summary> /// Initializes a new instance of the <see cref="OracleDatabaseComputedColumn"/> class. /// </summary> /// <param name="columnName">A column name.</param> /// <param name="type">A column type.</param> /// <param name="isNullable">If set to <c>true</c> is nullable.</param> /// <param name="definition">The computed column definition.</param> public OracleDatabaseComputedColumn(Identifier columnName, IDbType type, bool isNullable, Option <string> definition) : base(columnName, type, isNullable, definition) { Definition = definition; }
/// <summary> /// プロパティに結びつく列定義として初期化する /// </summary> /// <param name="environment">この列定義がベースとするDB接続環境</param> /// <param name="instance">プロパティを直接保持するオブジェクト</param> /// <param name="property">プロパティ情報</param> /// <param name="table">この列が所属する<see cref="ITable"/></param> /// <param name="name">DB上の列名</param> /// <param name="dbType">DB上の型</param> /// <param name="flags">列定義オプションフラグ</param> /// <param name="source">列を生成する元となった式</param> public Column(DbEnvironment environment, object instance, PropertyInfo property, ITable table, string name, IDbType dbType, ColumnFlags flags = 0, ElementCode source = null) { this.Environment = environment; this.Instance = instance; this.Property = property; this.Table = table; this.Name = name; this.DbType = dbType; this.Flags = flags; this.Source = source; }
public IDbType GetComparableColumnType(IDbType otherType) => CreateColumnType(null);
public GenericRepository(IDbType dbType) { _dbType = dbType; _repositoryType = typeof(T); }