Search Results for

    Show / Hide Table of Contents

    Interface IInsert<T1>

    Namespace: FreeSql
    Assembly: FreeSql.dll
    Syntax
    public interface IInsert<T1>
        where T1 : class
    Type Parameters
    Name Description
    T1

    Methods

    | Improve this Doc View Source

    AppendData(T1)

    追加准备插入的实体

    Declaration
    IInsert<T1> AppendData(T1 source)
    Parameters
    Type Name Description
    T1 source

    实体

    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    AppendData(T1[])

    追加准备插入的实体

    Declaration
    IInsert<T1> AppendData(T1[] source)
    Parameters
    Type Name Description
    T1[] source

    实体

    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    AppendData(IEnumerable<T1>)

    追加准备插入的实体集合

    Declaration
    IInsert<T1> AppendData(IEnumerable<T1> source)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<T1> source

    实体集合

    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    AsTable(Func<String, String>)

    设置表名规则,可用于分库/分表,参数1:默认表名;返回值:新表名;

    Declaration
    IInsert<T1> AsTable(Func<string, string> tableRule)
    Parameters
    Type Name Description
    System.Func<System.String, System.String> tableRule
    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    AsTable(String)

    设置表名

    Declaration
    IInsert<T1> AsTable(string tableName)
    Parameters
    Type Name Description
    System.String tableName
    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    AsType(Type)

    动态Type,在使用 Insert<object> 后使用本方法,指定实体类型

    Declaration
    IInsert<T1> AsType(Type entityType)
    Parameters
    Type Name Description
    System.Type entityType
    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    BatchOptions(Int32, Int32, Boolean)

    批量执行选项设置,一般不需要使用该方法

    各数据库 values, parameters 限制不一样,默认设置:

    MySql 5000 3000

    PostgreSQL 5000 3000

    SqlServer 1000 2100

    Oracle 500 999

    Sqlite 5000 999

    若没有事务传入,内部(默认)会自动开启新事务,保证拆包执行的完整性。

    Declaration
    IInsert<T1> BatchOptions(int valuesLimit, int parameterLimit, bool autoTransaction = true)
    Parameters
    Type Name Description
    System.Int32 valuesLimit

    指定根据 values 上限数量拆分执行

    System.Int32 parameterLimit

    指定根据 parameters 上限数量拆分执行

    System.Boolean autoTransaction

    是否自动开启事务

    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    BatchProgress(Action<BatchProgressStatus<T1>>)

    批量执行时,分批次执行的进度状态

    Declaration
    IInsert<T1> BatchProgress(Action<BatchProgressStatus<T1>> callback)
    Parameters
    Type Name Description
    System.Action<BatchProgressStatus<T1>> callback

    批量执行时的回调委托

    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    CommandTimeout(Int32)

    命令超时设置(秒)

    Declaration
    IInsert<T1> CommandTimeout(int timeout)
    Parameters
    Type Name Description
    System.Int32 timeout
    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    ExecuteAffrows()

    执行SQL语句,返回影响的行数

    Declaration
    int ExecuteAffrows()
    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    ExecuteAffrowsAsync(CancellationToken)

    Declaration
    Task<int> ExecuteAffrowsAsync(CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    System.Threading.CancellationToken cancellationToken
    Returns
    Type Description
    System.Threading.Tasks.Task<System.Int32>
    | Improve this Doc View Source

    ExecuteIdentity()

    执行SQL语句,返回自增值

    注意:请检查实体类是否标记了 [Column(IsIdentity = true)]

    Declaration
    long ExecuteIdentity()
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    ExecuteIdentityAsync(CancellationToken)

    Declaration
    Task<long> ExecuteIdentityAsync(CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    System.Threading.CancellationToken cancellationToken
    Returns
    Type Description
    System.Threading.Tasks.Task<System.Int64>
    | Improve this Doc View Source

    ExecuteInserted()

    执行SQL语句,返回插入后的记录

    注意:此方法只有 Postgresql/SqlServer 有效果

    Declaration
    List<T1> ExecuteInserted()
    Returns
    Type Description
    System.Collections.Generic.List<T1>
    | Improve this Doc View Source

    ExecuteInsertedAsync(CancellationToken)

    Declaration
    Task<List<T1>> ExecuteInsertedAsync(CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    System.Threading.CancellationToken cancellationToken
    Returns
    Type Description
    System.Threading.Tasks.Task<System.Collections.Generic.List<T1>>
    | Improve this Doc View Source

    IgnoreColumns(Expression<Func<T1, Object>>)

    忽略的列,IgnoreColumns(a => a.Name) | IgnoreColumns(a => new{a.Name,a.Time}) | IgnoreColumns(a => new[]{"name","time"})

    Declaration
    IInsert<T1> IgnoreColumns(Expression<Func<T1, object>> columns)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression<System.Func<T1, System.Object>> columns

    lambda选择列

    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    IgnoreColumns(String[])

    忽略的列

    Declaration
    IInsert<T1> IgnoreColumns(string[] columns)
    Parameters
    Type Name Description
    System.String[] columns

    属性名,或者字段名

    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    IgnoreInsertValueSql(Expression<Func<T1, Object>>)

    忽略 InsertValueSql 设置,将使用实体对象的值插入

    IgnoreInsertValueSql(a => a.Name) | IgnoreInsertValueSql(a => new{a.Name,a.Time}) | IgnoreInsertValueSql(a => new[]{"name","time"})

    Declaration
    IInsert<T1> IgnoreInsertValueSql(Expression<Func<T1, object>> columns)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression<System.Func<T1, System.Object>> columns

    属性名,或者字段名

    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    InsertColumns(Expression<Func<T1, Object>>)

    只插入的列,InsertColumns(a => a.Name) | InsertColumns(a => new{a.Name,a.Time}) | InsertColumns(a => new[]{"name","time"})

    Declaration
    IInsert<T1> InsertColumns(Expression<Func<T1, object>> columns)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression<System.Func<T1, System.Object>> columns

    lambda选择列

    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    InsertColumns(String[])

    只插入的列

    Declaration
    IInsert<T1> InsertColumns(string[] columns)
    Parameters
    Type Name Description
    System.String[] columns

    属性名,或者字段名

    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    InsertIdentity()

    指定可插入自增字段

    Declaration
    IInsert<T1> InsertIdentity()
    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    NoneParameter(Boolean)

    不使用参数化,可通过 IFreeSql.CodeFirst.IsNotCommandParameter 全局性设置

    Declaration
    IInsert<T1> NoneParameter(bool isNotCommandParameter = true)
    Parameters
    Type Name Description
    System.Boolean isNotCommandParameter

    是否不使用参数化

    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    ToDataTable()

    返回 DataTable 以便做 BulkCopy 数据做准备

    此方法会处理:

    类型、表名、字段名映射

    IgnoreColumns、InsertColumns

    Declaration
    DataTable ToDataTable()
    Returns
    Type Description
    System.Data.DataTable
    | Improve this Doc View Source

    ToSql()

    返回即将执行的SQL语句

    Declaration
    string ToSql()
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    WithConnection(DbConnection)

    指定事务对象

    Declaration
    IInsert<T1> WithConnection(DbConnection connection)
    Parameters
    Type Name Description
    System.Data.Common.DbConnection connection
    Returns
    Type Description
    IInsert<T1>
    | Improve this Doc View Source

    WithTransaction(DbTransaction)

    指定事务对象

    Declaration
    IInsert<T1> WithTransaction(DbTransaction transaction)
    Parameters
    Type Name Description
    System.Data.Common.DbTransaction transaction
    Returns
    Type Description
    IInsert<T1>
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX