- 增加 PostgreSQL 特有功能 On Conflict Do Update 功能;

This commit is contained in:
28810
2019-11-13 16:21:30 +08:00
parent b43f9b6688
commit e0030b0c00
10 changed files with 492 additions and 35 deletions

View File

@ -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);
}