PetaPoco - 插入数据库时的事务隔离级别

3
有没有办法使用PetaPoco在插入数据库时设置隔离级别!
事务在未完成时锁定数据库,我知道有一些方法可以编辑实际的查询或存储过程,但是否有一种通过petapoco控制隔离级别的方法呢?似乎早期版本中有一个选项,但在最新版本中找不到任何东西。
我的当前示例代码:
using (var scope = contextasync.getInstance().GetTransaction())
{
    try {
        object userId = context.Insert(user);
        example.UserId = user.Id;
        object affected2 = context.Insert(example); }catch(Exception exc)
    {
        //log the error

    }
scope.Complete();

}

我看了一下,但并没有帮助:PetaPoco - 设置事务隔离级别


请您标记此问题已解决。谢谢。 - Plebsori
1个回答

2

最新版本的PetaPoco允许您设置隔离级别。

使用流畅配置

var db = config.Build()
         .UsingConnectionString("cs")
         .UsingProvider<SqlServerDatabaseProvider>()
         .UsingIsolationLevel(IsolationLevel.Chaos)
         .Create();

 db.IsolationLevel.ShouldBe(IsolationLevel.Chaos);

或传统构造函数

var db = new Database("MyConnectionStringName") { IsolationLevel = IsolationLevel.Chaos };

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接