Interface IInsertOrUpdate<T1>
Assembly: FreeSql.dll
Syntax
public interface IInsertOrUpdate<T1>
where T1 : class
Type Parameters
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
|
Improve this Doc
View Source
AsTable(String)
Declaration
IInsertOrUpdate<T1> AsTable(string tableName)
Parameters
Type |
Name |
Description |
System.String |
tableName |
|
Returns
|
Improve this Doc
View Source
AsType(Type)
动态Type,在使用 Update<object> 后使用本方法,指定实体类型
Declaration
IInsertOrUpdate<T1> AsType(Type entityType)
Parameters
Type |
Name |
Description |
System.Type |
entityType |
|
Returns
|
Improve this Doc
View Source
CommandTimeout(Int32)
Declaration
IInsertOrUpdate<T1> CommandTimeout(int timeout)
Parameters
Type |
Name |
Description |
System.Int32 |
timeout |
|
Returns
|
Improve this Doc
View Source
ExecuteAffrows()
Declaration
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
|
Improve this Doc
View Source
SetSource(T1)
Declaration
IInsertOrUpdate<T1> SetSource(T1 source)
Parameters
Type |
Name |
Description |
T1 |
source |
实体
|
Returns
|
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
|
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
|
Improve this Doc
View Source
SetSource(String, Expression<Func<T1, Object>>)
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
|
Improve this Doc
View Source
ToSql()
Declaration
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
|
Improve this Doc
View Source
UpdateColumns(String[])
Declaration
IInsertOrUpdate<T1> UpdateColumns(string[] columns)
Parameters
Type |
Name |
Description |
System.String[] |
columns |
属性名,或者字段名
|
Returns
|
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 Parameters
|
Improve this Doc
View Source
WithConnection(DbConnection)
Declaration
IInsertOrUpdate<T1> WithConnection(DbConnection connection)
Parameters
Type |
Name |
Description |
System.Data.Common.DbConnection |
connection |
|
Returns
|
Improve this Doc
View Source
WithTransaction(DbTransaction)
Declaration
IInsertOrUpdate<T1> WithTransaction(DbTransaction transaction)
Parameters
Type |
Name |
Description |
System.Data.Common.DbTransaction |
transaction |
|
Returns