Search Results for

    Show / Hide Table of Contents

    Interface IInsertOrUpdate<T1>

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

    Methods

    | Improve this Doc View Source

    AsTable(Func<String, String>)

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

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

    AsTable(String)

    设置表名

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

    AsType(Type)

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

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

    CommandTimeout(Int32)

    命令超时设置(秒)

    Declaration
    IInsertOrUpdate<T1> CommandTimeout(int timeout)
    Parameters
    Type Name Description
    System.Int32 timeout
    Returns
    Type Description
    IInsertOrUpdate<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

    IfExistsDoNothing()

    当记录存在时,什么都不做

    换句话:只有记录不存在时才插入

    Declaration
    IInsertOrUpdate<T1> IfExistsDoNothing()
    Returns
    Type Description
    IInsertOrUpdate<T1>
    | Improve this Doc View Source

    SetSource(T1)

    添加或更新,设置实体

    Declaration
    IInsertOrUpdate<T1> SetSource(T1 source)
    Parameters
    Type Name Description
    T1 source

    实体

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

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

    添加或更新,设置实体

    Declaration
    IInsertOrUpdate<T1> SetSource(T1 source, Expression<Func<T1, object>> tempPrimarys)
    Parameters
    Type Name Description
    T1 source

    实体

    System.Linq.Expressions.Expression<System.Func<T1, System.Object>> tempPrimarys

    根据临时主键插入或更新,a => a.Name | a => new{a.Name,a.Time} | a => new[]{"name","time"}

    注意:不处理自增,因某些数据库依赖主键或唯一键,所以指定临时主键仅对 SqlServer/PostgreSQL/Firebird/达梦/南大通用/金仓/神通 有效

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

    SetSource(IEnumerable<T1>, Expression<Func<T1, Object>>)

    添加或更新,设置实体集合

    Declaration
    IInsertOrUpdate<T1> SetSource(IEnumerable<T1> source, Expression<Func<T1, object>> tempPrimarys = null)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<T1> source

    实体集合

    System.Linq.Expressions.Expression<System.Func<T1, System.Object>> tempPrimarys

    根据临时主键插入或更新,a => a.Name | a => new{a.Name,a.Time} | a => new[]{"name","time"}

    注意:不处理自增,因某些数据库依赖主键或唯一键,所以指定临时主键仅对 SqlServer/PostgreSQL/Firebird/达梦/南大通用/金仓/神通 有效

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

    SetSource(String, Expression<Func<T1, Object>>)

    添加或更新,设置SQL

    Declaration
    IInsertOrUpdate<T1> SetSource(string sql, Expression<Func<T1, object>> tempPrimarys = null)
    Parameters
    Type Name Description
    System.String sql

    查询SQL

    System.Linq.Expressions.Expression<System.Func<T1, System.Object>> tempPrimarys

    根据临时主键插入或更新,a => a.Name | a => new{a.Name,a.Time} | a => new[]{"name","time"}

    注意:不处理自增,因某些数据库依赖主键或唯一键,所以指定临时主键仅对 SqlServer/PostgreSQL/Firebird/达梦/南大通用/金仓/神通 有效

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

    ToSql()

    返回即将执行的SQL语句

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

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

    当记录存在时,指定只更新的字段,UpdateColumns(a => a.Name) | UpdateColumns(a => new{a.Name,a.Time}) | UpdateColumns(a => new[]{"name","time"})

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

    lambda选择列

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

    UpdateColumns(String[])

    当记录存在时,指定只更新的字段

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

    属性名,或者字段名

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

    UpdateSet<TMember>(Expression<Func<T1, T1, TMember>>)

    设置列的联表值,格式:

    UpdateSet((a, b) => a.Clicks == b.xxx)

    UpdateSet((a, b) => a.Clicks == a.Clicks + 1)

    Declaration
    IInsertOrUpdate<T1> UpdateSet<TMember>(Expression<Func<T1, T1, TMember>> exp)
    Parameters
    Type Name Description
    System.Linq.Expressions.Expression<System.Func<T1, T1, TMember>> exp
    Returns
    Type Description
    IInsertOrUpdate<T1>
    Type Parameters
    Name Description
    TMember
    | Improve this Doc View Source

    WithConnection(DbConnection)

    指定事务对象

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

    WithTransaction(DbTransaction)

    指定事务对象

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