Search Results for

    Show / Hide Table of Contents

    Class ColumnFluent

    Inheritance
    System.Object
    ColumnFluent
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: FreeSql.DataAnnotations
    Assembly: FreeSql.dll
    Syntax
    public class ColumnFluent

    Constructors

    | Improve this Doc View Source

    ColumnFluent(ColumnAttribute, PropertyInfo, Type)

    Declaration
    public ColumnFluent(ColumnAttribute column, PropertyInfo property, Type entityType)
    Parameters
    Type Name Description
    ColumnAttribute column
    System.Reflection.PropertyInfo property
    System.Type entityType

    Fields

    | Improve this Doc View Source

    _column

    Declaration
    public ColumnAttribute _column
    Field Value
    Type Description
    ColumnAttribute
    | Improve this Doc View Source

    _entityType

    Declaration
    public Type _entityType
    Field Value
    Type Description
    System.Type
    | Improve this Doc View Source

    _property

    Declaration
    public PropertyInfo _property
    Field Value
    Type Description
    System.Reflection.PropertyInfo

    Methods

    | Improve this Doc View Source

    CanInsert(Boolean)

    该字段是否可以插入,默认值true,指定为false插入时该字段会被忽略

    Declaration
    public ColumnFluent CanInsert(bool value)
    Parameters
    Type Name Description
    System.Boolean value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    CanUpdate(Boolean)

    该字段是否可以更新,默认值true,指定为false更新时该字段会被忽略

    Declaration
    public ColumnFluent CanUpdate(bool value)
    Parameters
    Type Name Description
    System.Boolean value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    DbType(String)

    数据库类型,如: varchar(255)

    Declaration
    public ColumnFluent DbType(string value)
    Parameters
    Type Name Description
    System.String value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    InsertValueSql(String)

    执行 Insert 方法时使用此值

    注意:如果是 getdate() 这种请可考虑使用 ServerTime,因为它对数据库间作了适配

    Declaration
    public ColumnFluent InsertValueSql(string value)
    Parameters
    Type Name Description
    System.String value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    IsIdentity(Boolean)

    自增标识

    Declaration
    public ColumnFluent IsIdentity(bool value)
    Parameters
    Type Name Description
    System.Boolean value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    IsIgnore(Boolean)

    忽略此列,不迁移、不插入

    Declaration
    public ColumnFluent IsIgnore(bool value)
    Parameters
    Type Name Description
    System.Boolean value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    IsNullable(Boolean)

    是否可DBNull

    Declaration
    public ColumnFluent IsNullable(bool value)
    Parameters
    Type Name Description
    System.Boolean value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    IsPrimary(Boolean)

    主键

    Declaration
    public ColumnFluent IsPrimary(bool value)
    Parameters
    Type Name Description
    System.Boolean value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    IsVersion(Boolean)

    乐观锁

    Declaration
    public ColumnFluent IsVersion(bool value)
    Parameters
    Type Name Description
    System.Boolean value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    MapType(Type)

    类型映射,比如:可将 enum 属性映射成 typeof(string)

    Declaration
    public ColumnFluent MapType(Type value)
    Parameters
    Type Name Description
    System.Type value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    Name(String)

    数据库列名

    Declaration
    public ColumnFluent Name(string value)
    Parameters
    Type Name Description
    System.String value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    OldName(String)

    指定数据库旧的列名,修改实体属性命名时,同时设置此参数为修改之前的值,CodeFirst才可以正确修改数据库字段;否则将视为【新增字段】

    Declaration
    public ColumnFluent OldName(string value)
    Parameters
    Type Name Description
    System.String value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    Position(Int16)

    创建表时字段位置,规则如下:

    >0时排前面

    =0时排中间(默认)

    <0时排后面

    Declaration
    public ColumnFluent Position(short value)
    Parameters
    Type Name Description
    System.Int16 value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    Precision(Int32, Int32)

    decimal/numeric 类型的长度/小数位长度

    Declaration
    public ColumnFluent Precision(int precision, int scale = 0)
    Parameters
    Type Name Description
    System.Int32 precision

    总长度

    System.Int32 scale

    小数位长度

    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    RereadSql(String)

    重读功能

    比如:[Column(RereadSql = "{0}.STAsText()")]

    查询:SELECT a.[id], a.[geo].STAsText() FROM [table] a

    Declaration
    public ColumnFluent RereadSql(string value)
    Parameters
    Type Name Description
    System.String value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    RewriteSql(String)

    重写功能

    比如:[Column(RewriteSql = "geography::STGeomFromText({0},4236)")]

    插入:INSERT INTO table VALUES(geography::STGeomFromText('...',4236))

    提示:更新也生效

    Declaration
    public ColumnFluent RewriteSql(string value)
    Parameters
    Type Name Description
    System.String value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    ServerTime(DateTimeKind)

    标记属性为数据库服务器时间(utc/local),在插入的时候使用类似 getdate() 执行

    Declaration
    public ColumnFluent ServerTime(DateTimeKind value)
    Parameters
    Type Name Description
    System.DateTimeKind value
    Returns
    Type Description
    ColumnFluent
    | Improve this Doc View Source

    StringLength(Int32)

    设置长度,针对 string 类型避免 DbType 的繁琐设置

    ---

    StringLength = 100 时,对应 DbType:

    MySql -> varchar(100)

    SqlServer -> nvarchar(100)

    PostgreSQL -> varchar(100)

    Oracle -> nvarchar2(100)

    Sqlite -> nvarchar(100)

    ---

    StringLength = -1 时,对应 DbType:

    MySql -> text

    SqlServer -> nvarchar(max)

    PostgreSQL -> text

    Oracle -> nvarchar2(4000)

    Sqlite -> text

    Declaration
    public ColumnFluent StringLength(int value)
    Parameters
    Type Name Description
    System.Int32 value
    Returns
    Type Description
    ColumnFluent
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX