-
Notifications
You must be signed in to change notification settings - Fork 861
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中使用InsertOrUpdate时,使用外部事务时时会抛数据库被锁定的异常 #402
Comments
是不是因为开启了自动迁移,首次使用实体的时候如果在事务内是会这样,首次使用在外面就没事 |
没有,完整的测试代码 static IFreeSql fsql = new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.Sqlite, @"Data Source=D:\Data\db1.db")
//.UseAutoSyncStructure(true) //自动同步实体结构到数据库
.Build(); //请务必定义成 Singleton 单例模式
private void test(){
fsql.Transaction(() =>
{
fsql.InsertOrUpdate<Test>().SetSource(new Test()
{
Id = 1,
Name = "test"
}).ExecuteAffrows();
});
} |
2881099
pushed a commit
that referenced
this issue
Aug 3, 2020
暂时可以先这样解决: private void test(){
fsql.Transaction(() =>
{
fsql.InsertOrUpdate<Test>()
.WithTransaction(fsqlTransactionCurrentThread) //1.7.1 手工传递事务解决
.SetSource(new Test()
{
Id = 1,
Name = "test"
}).ExecuteAffrows();
});
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
在Sqlite中使用事务保存时,抛数据库被锁定得异常。
测试代码如下
fsql.Transaction(() =>
{
fsql.InsertOrUpdate().SetSource(new Test()
{
Id = 1,
Name = "test"
}).ExecuteAffrows();
});
不使用 Transaction 时,可以正常执行。使用Transaction时就会抛数据库被锁定得异常
The text was updated successfully, but these errors were encountered: