mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 增加 PostgreSQL 特有功能 On Conflict Do Update 功能;
This commit is contained in:
@ -1,4 +1,9 @@
|
||||
public static partial class FreeSqlPostgreSQLGlobalExtensions
|
||||
using FreeSql;
|
||||
using FreeSql.PostgreSQL.Curd;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
public static partial class FreeSqlPostgreSQLGlobalExtensions
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
@ -9,4 +14,14 @@
|
||||
/// <returns></returns>
|
||||
public static string FormatPostgreSQL(this string that, params object[] args) => _postgresqlAdo.Addslashes(that, args);
|
||||
static FreeSql.PostgreSQL.PostgreSQLAdo _postgresqlAdo = new FreeSql.PostgreSQL.PostgreSQLAdo();
|
||||
|
||||
/// <summary>
|
||||
/// PostgreSQL9.5+ 特有的功能,On Conflict Do Update<para></para>
|
||||
/// 注意:此功能会开启插入【自增列】
|
||||
/// </summary>
|
||||
/// <typeparam name="T1"></typeparam>
|
||||
/// <param name="that"></param>
|
||||
/// <param name="columns">默认是以主键作为重复判断,也可以指定其他列:a => a.Name | a => new{a.Name,a.Time} | a => new[]{"name","time"}</param>
|
||||
/// <returns></returns>
|
||||
public static OnConflictDoUpdate<T1> OnConflictDoUpdate<T1>(this IInsert<T1> that, Expression<Func<T1, object>> columns = null) where T1 : class => new FreeSql.PostgreSQL.Curd.OnConflictDoUpdate<T1>(that.InsertIdentity(), columns);
|
||||
}
|
||||
|
Reference in New Issue
Block a user