Sqlite如何使用InsertOrUpdate类似于指定临时主键功能 #1669
Answered
by
2881099
deanlee2021
asked this question in
Q&A
-
在Sqlite中使用 public static int NewInsertDataToDb(List<TestData> dataList)
{
if (dataList == null || dataList.Count == 0) return -1;
return Db.SqlServer.InsertOrUpdate<TestData>().SetSource(dataList, a => a.Name).IfExistsDoNothing().ExecuteAffrows();
} 根据pr(pr链接)中的提示《不处理自增,因某些数据库依赖主键或唯一键,所以指定临时主键仅对 SqlServer/PostgreSQL/Firebird/达梦/南大通用/金仓/神通 有效》 如果在Sqlite中想使用相同的功能,该如何实现呢? |
Beta Was this translation helpful? Give feedback.
Answered by
2881099
Nov 16, 2023
Replies: 1 comment
-
使用前先把id查询出来,若有则填充到实体上,再进行操作 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
deanlee2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使用前先把id查询出来,若有则填充到实体上,再进行操作