- 增加 IInsertOrUpdate.SetSource(items, tempPrimarys) 指定临时主键参数;#1160

This commit is contained in:
2881099
2022-06-22 21:09:04 +08:00
parent 5fec1254cf
commit 1155ffc781
27 changed files with 109 additions and 101 deletions

View File

@ -46,14 +46,14 @@ namespace FreeSql.Odbc.MySql
insert.InsertIdentity();
if (_doNothing == false)
{
var cols = _table.Columns.Values.Where(a => a.Attribute.IsPrimary == false && a.Attribute.CanUpdate == true && _updateIgnore.ContainsKey(a.Attribute.Name) == false);
var cols = _table.Columns.Values.Where(a => _tempPrimarys.Contains(a) == false && a.Attribute.CanUpdate == true && _updateIgnore.ContainsKey(a.Attribute.Name) == false);
sql = new OdbcMySqlOnDuplicateKeyUpdate<T1>(insert)
.UpdateColumns(cols.Select(a => a.Attribute.Name).ToArray())
.ToSql();
}
else
{
if (_table.Primarys.Any() == false) throw new Exception(CoreStrings.Entity_Must_Primary_Key("fsql.InsertOrUpdate + IfExistsDoNothing + MySql ", _table.CsName));
if (_tempPrimarys.Any() == false) throw new Exception(CoreStrings.Entity_Must_Primary_Key("fsql.InsertOrUpdate + IfExistsDoNothing + MySql ", _table.CsName));
sql = insert.ToSqlValuesOrSelectUnionAllExtension101(false, (rowd, idx, sb) =>
sb.Append(" \r\n FROM dual WHERE NOT EXISTS(").Append(
_orm.Select<T1>()