Search Results for

    Show / Hide Table of Contents

    Class ColumnAttribute

    Configures mapping of mapping class member to database column. Could be applied directly to a property or field or to mapping class/interface. In latter case you should specify member name using MemberName property.

    Inheritance
    System.Object
    MappingAttribute
    ColumnAttribute
    NotColumnAttribute
    Namespace: LinqToDB.Mapping
    Assembly: linq2db.dll
    Syntax
    public class ColumnAttribute : MappingAttribute

    Constructors

    | Improve this Doc View Source

    ColumnAttribute()

    Creates attribute instance.

    Declaration
    public ColumnAttribute()
    | Improve this Doc View Source

    ColumnAttribute(String)

    Creates attribute instance.

    Declaration
    public ColumnAttribute(string columnName)
    Parameters
    Type Name Description
    System.String columnName

    Database column name.

    | Improve this Doc View Source

    ColumnAttribute(String, String)

    Creates attribute instance.

    Declaration
    public ColumnAttribute(string columnName, string memberName)
    Parameters
    Type Name Description
    System.String columnName

    Database column name.

    System.String memberName

    Name of mapped member. See MemberName for more details.

    Properties

    | Improve this Doc View Source

    CanBeNull

    Gets or sets whether a column can contain NULL values.

    Declaration
    public bool CanBeNull { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Configuration

    Gets or sets mapping schema configuration name, for which this attribute should be taken into account. ProviderName for standard names. Attributes with null or empty string Configuration value applied to all configurations (if no attribute found for current configuration).

    Declaration
    public string? Configuration { get; set; }
    Property Value
    Type Description
    System.Nullable<System.String>
    | Improve this Doc View Source

    CreateFormat

    Custom template for column definition in create table SQL expression, generated using CreateTable<T>(IDataContext, Nullable<String>, Nullable<String>, Nullable<String>, Nullable<String>, Nullable<String>, DefaultNullable, Nullable<String>, TableOptions) methods. Template accepts following string parameters:

    • {0} - column name;
    • {1} - column type;
    • {2} - NULL specifier;
    • {3} - identity specification.
    Declaration
    public string? CreateFormat { get; set; }
    Property Value
    Type Description
    System.Nullable<System.String>
    | Improve this Doc View Source

    DataType

    Gets or sets linq2db type for column. Default value: default type, defined for member type in mapping schema.

    Declaration
    public DataType DataType { get; set; }
    Property Value
    Type Description
    DataType
    | Improve this Doc View Source

    DbType

    Gets or sets the name of the database column type. Default value: default type, defined for member type in mapping schema.

    Declaration
    public string? DbType { get; set; }
    Property Value
    Type Description
    System.Nullable<System.String>
    | Improve this Doc View Source

    IsColumn

    Gets or sets flag that tells that current member should be included into mapping. Use NonColumnAttribute instead as a shorthand. Default value: true.

    Declaration
    public bool IsColumn { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsDiscriminator

    Gets or sets whether a column contains a discriminator value for a LINQ to DB inheritance hierarchy. InheritanceMappingAttribute for more details. Default value: false.

    Declaration
    public bool IsDiscriminator { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsIdentity

    Gets or sets whether a column contains values that the database auto-generates. Also see IdentityAttribute.

    Declaration
    public bool IsIdentity { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsPrimaryKey

    Gets or sets whether this class member represents a column that is part or all of the primary key of the table. Also see PrimaryKeyAttribute.

    Declaration
    public bool IsPrimaryKey { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Length

    Gets or sets the length of the database column. Default value: value, defined for member type in mapping schema.

    Declaration
    public int Length { get; set; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    MemberName

    Gets or sets the name of mapped member. When applied to class or interface, should contain name of property of field.

    If column mapped to a property or field of composite object, MemberName should contain a path to that member using dot as separator.

    public class Address
    {
        public string City     { get; set; }
        public string Street   { get; set; }
        public int    Building { get; set; }
    }
    
    [Column("city", "Residence.City")]
    [Column("user_name", "Name")]
    public class User
    {
        public string Name;
    
        [Column("street", ".Street")]
        [Column("building_number", MemberName = ".Building")]
        public Address Residence { get; set; }
    }

    Declaration
    public string? MemberName { get; set; }
    Property Value
    Type Description
    System.Nullable<System.String>
    | Improve this Doc View Source

    Name

    Gets or sets the name of a column in database. If not specified, member name will be used.

    Declaration
    public string? Name { get; set; }
    Property Value
    Type Description
    System.Nullable<System.String>
    | Improve this Doc View Source

    Order

    Specifies the order of the field in table creation. Positive values first (ascending), then unspecified (arbitrary), then negative values (ascending).

    Declaration
    public int Order { get; set; }
    Property Value
    Type Description
    System.Int32
    Remarks

    Ordering performed in SqlTable constructor.

    | Improve this Doc View Source

    Precision

    Gets or sets the precision of the database column. Default value: value, defined for member type in mapping schema.

    Declaration
    public int Precision { get; set; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    PrimaryKeyOrder

    Gets or sets the Primary Key order. See Order for more details.

    Declaration
    public int PrimaryKeyOrder { get; set; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    Scale

    Gets or sets the Scale of the database column. Default value: value, defined for member type in mapping schema.

    Declaration
    public int Scale { get; set; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    SkipOnEntityFetch

    Gets or sets whether a column must be explicitly defined in a Select statement to be fetched. If true, a "SELECT *"-ish statement won't retrieve this column. Default value: false.

    Declaration
    public bool SkipOnEntityFetch { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    SkipOnInsert

    Gets or sets whether a column is insertable. This flag will affect only insert operations with implicit columns specification like Insert<T>(IDataContext, T, Nullable<String>, Nullable<String>, Nullable<String>, Nullable<String>, TableOptions) method and will be ignored when user explicitly specifies value for this column.

    Declaration
    public bool SkipOnInsert { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    SkipOnUpdate

    Gets or sets whether a column is updatable. This flag will affect only update operations with implicit columns specification like Update<T>(IDataContext, T, Nullable<String>, Nullable<String>, Nullable<String>, Nullable<String>, TableOptions) method and will be ignored when user explicitly specifies value for this column.

    Declaration
    public bool SkipOnUpdate { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Storage

    Gets or sets a storage property or field to hold the value from a column. Could be usefull e.g. in combination of private storage field and getter-only mapping property.

    Declaration
    public string? Storage { get; set; }
    Property Value
    Type Description
    System.Nullable<System.String>

    Methods

    | Improve this Doc View Source

    GetObjectID()

    Declaration
    public override string GetObjectID()
    Returns
    Type Description
    System.String
    Overrides
    MappingAttribute.GetObjectID()

    Extension Methods

    Map.DeepCopy<T>(T)
    Sql.IsDistinctFrom<T>(T, T)
    Sql.IsNotDistinctFrom<T>(T, T)
    SqlExtensions.In<T>(T, IEnumerable<T>)
    SqlExtensions.In<T>(T, IQueryable<T>)
    SqlExtensions.In<T>(T, T[])
    SqlExtensions.In<T>(T, T, T)
    SqlExtensions.In<T>(T, T, T, T)
    SqlExtensions.NotIn<T>(T, IEnumerable<T>)
    SqlExtensions.NotIn<T>(T, IQueryable<T>)
    SqlExtensions.NotIn<T>(T, T[])
    SqlExtensions.NotIn<T>(T, T, T)
    SqlExtensions.NotIn<T>(T, T, T, T)
    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2011-2022 linq2db.com

    Generated by DocFX