mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Synchronization code
This commit is contained in:
parent
e3f5ba7cca
commit
3d494f40b8
@ -557,7 +557,11 @@ namespace SqlSugar
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public IInsertable<T> PostgreSQLConflictNothing(string[] columns)
|
||||
{
|
||||
this.InsertBuilder.ConflictNothing = columns;
|
||||
return this;
|
||||
}
|
||||
public IInsertable<T> MySqlIgnore()
|
||||
{
|
||||
this.InsertBuilder.MySqlIgnore = true;
|
||||
|
@ -133,6 +133,7 @@ namespace SqlSugar
|
||||
|
||||
public bool MySqlIgnore { get; internal set; }
|
||||
public bool IsWithAttr { get; internal set; }
|
||||
public string[] ConflictNothing { get; set; }
|
||||
|
||||
public virtual ExpressionResult GetExpressionValue(Expression expression, ResolveExpressType resolveType)
|
||||
{
|
||||
|
@ -64,6 +64,7 @@ namespace SqlSugar
|
||||
SplitInsertable<T> SplitTable(SplitType splitType);
|
||||
void AddQueue();
|
||||
IInsertable<T> MySqlIgnore();
|
||||
IInsertable<T> PostgreSQLConflictNothing(string[] columns);
|
||||
IInsertable<T> OffIdentity();
|
||||
IInsertable<T> OffIdentity(bool isSetOn);
|
||||
InsertablePage<T> PageSize(int pageSize);
|
||||
|
@ -49,7 +49,7 @@ namespace SqlSugar
|
||||
{
|
||||
string columnParametersString = string.Join(",", this.DbColumnInfoList.Select(it =>base.GetDbColumn(it, Builder.SqlParameterKeyWord + it.DbColumnName)));
|
||||
ActionMinDate();
|
||||
return string.Format(SqlTemplate, GetTableNameString, columnsString, columnParametersString);
|
||||
return GetIgnoreSql(string.Format(SqlTemplate, GetTableNameString, columnsString, columnParametersString));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -116,7 +116,7 @@ namespace SqlSugar
|
||||
pageIndex++;
|
||||
batchInsetrSql.Remove(batchInsetrSql.Length - 1,1).Append("\r\n;\r\n");
|
||||
}
|
||||
return batchInsetrSql.ToString();
|
||||
return GetIgnoreSql(batchInsetrSql.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,6 +182,15 @@ namespace SqlSugar
|
||||
{
|
||||
return "'" + ((DateTimeOffset)value).ToString("o") + "'";
|
||||
}
|
||||
|
||||
private string GetIgnoreSql(string sql)
|
||||
{
|
||||
if (this.ConflictNothing?.Any() == true)
|
||||
{
|
||||
sql = sql.Replace(";", $" ON CONFLICT ({string.Join(",", this.ConflictNothing)}) DO NOTHING;");
|
||||
}
|
||||
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user