mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 20:38:16 +08:00
- 补充 fsql.InsertOrUpdate IfExistsDoNothing 数据存在时不做任何事(不更新) #330 #316;
This commit is contained in:
@ -19,6 +19,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
protected CommonUtils _commonUtils;
|
||||
protected CommonExpression _commonExpression;
|
||||
protected List<T1> _source = new List<T1>();
|
||||
protected bool _doNothing = false;
|
||||
protected Dictionary<string, bool> _auditValueChangedDict = new Dictionary<string, bool>(StringComparer.CurrentCultureIgnoreCase);
|
||||
protected TableInfo _table;
|
||||
protected Func<string, string> _tableRule;
|
||||
@ -106,6 +107,12 @@ namespace FreeSql.Internal.CommonProvider
|
||||
return this;
|
||||
}
|
||||
|
||||
public IInsertOrUpdate<T1> IfExistsDoNothing()
|
||||
{
|
||||
_doNothing = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected string TableRuleInvoke()
|
||||
{
|
||||
if (_tableRule == null) return _table.DbName;
|
||||
|
@ -494,7 +494,8 @@ namespace FreeSql.Internal.CommonProvider
|
||||
|
||||
public virtual string ToSql() => ToSqlValuesOrSelectUnionAll(true);
|
||||
|
||||
public string ToSqlValuesOrSelectUnionAll(bool isValues = true)
|
||||
public string ToSqlValuesOrSelectUnionAll(bool isValues = true) => ToSqlValuesOrSelectUnionAllExtension101(isValues, null);
|
||||
public string ToSqlValuesOrSelectUnionAllExtension101(bool isValues, Action<object, int, StringBuilder> onrow)
|
||||
{
|
||||
if (_source == null || _source.Any() == false) return null;
|
||||
var sb = new StringBuilder();
|
||||
@ -541,6 +542,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
++colidx2;
|
||||
}
|
||||
if (isValues) sb.Append(")");
|
||||
onrow?.Invoke(d, didx, sb);
|
||||
++didx;
|
||||
}
|
||||
if (_noneParameter && specialParams.Any())
|
||||
|
Reference in New Issue
Block a user