Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite异步SaveAsync 执行Insert Into Table Do Update操作缺少主键填充,执行了Insert #5

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions XCode/Entity/EntityExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ public static Int32 Upsert<T>(this IEnumerable<T> list, IDataColumn[] columns =
var dbt = session.Dal.DbType;
if (dbt is DatabaseType.SqlServer or DatabaseType.Oracle)
columns = fact.Fields.Select(e => e.Field).Where(e => !e.Identity || e.PrimaryKey).ToArray();
else if (dbt == DatabaseType.MySql)
else if (dbt is DatabaseType.MySql or DatabaseType.SQLite) //SQLite库集合更新这里用到了Insert Into Do Update,所以不能排除主键填充,所以这里增加了 or DatabaseType.SQLite
columns = fact.Fields.Select(e => e.Field).ToArray(); //只有标识键的情况下会导致重复执行insert方法 目前只测试了Mysql库
else
columns = fact.Fields.Select(e => e.Field).Where(e => !e.Identity).ToArray();
Expand Down Expand Up @@ -1156,4 +1156,4 @@ public static DataSet ToDataSet<T>(this IEnumerable<T> list) where T : IEntity
}
#endregion
}
}
}