Skip to content

Commit 87f2cba

Browse files
committed
- 修复 2.0.103 Uow.Orm 事务 bug;
1 parent ff1354d commit 87f2cba

File tree

5 files changed

+215
-10
lines changed

5 files changed

+215
-10
lines changed

FreeSql.DbContext/DbContext/DbContextScopedFreeSql.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public ScopeTransactionAdo(AdoProvider ado, Func<DbTransaction> resolveTran) : b
4848
base.ConnectionString = ado.ConnectionString;
4949
base.SlaveConnectionStrings = ado.SlaveConnectionStrings;
5050
base.Identifier = ado.Identifier;
51+
base.MasterPool = ado.MasterPool;
52+
base._util = ado._util;
5153
}
5254
public override object AddslashesProcessParam(object param, Type mapType, ColumnInfo mapColumn) => _ado.AddslashesProcessParam(param, mapType, mapColumn);
5355
public override DbCommand CreateCommand() => _ado.CreateCommand();

FreeSql.DbContext/FreeSql.DbContext.xml

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeSql.Tests/FreeSql.Tests.DbContext/RepositoryTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,35 @@ class BeginEdit01
499499
public string Name { get; set; }
500500
}
501501

502+
[Fact]
503+
public void OrmScoped()
504+
{
505+
var fsql = g.sqlserver;
506+
//fsql.Aop.CommandBefore += (s, e) =>
507+
//{
508+
// Console.WriteLine(e.Command.CommandText);
509+
//};
510+
511+
var repo = fsql.GetRepository<ts_repo_update_bit>();
512+
repo.Orm.Ado.ExecuteNonQuery("select 1");
513+
514+
using (var ctx = fsql.CreateDbContext())
515+
{
516+
ctx.Orm.Ado.ExecuteNonQuery("select 1");
517+
}
518+
519+
using (var uow = fsql.CreateUnitOfWork())
520+
{
521+
uow.Orm.Ado.ExecuteNonQuery("select 1");
522+
}
523+
524+
using (var uow = fsql.CreateUnitOfWork())
525+
{
526+
repo.UnitOfWork = uow;
527+
repo.Orm.Ado.ExecuteNonQuery("select 1");
528+
}
529+
}
530+
502531
[Fact]
503532
public void UpdateBit()
504533
{

FreeSql/FreeSql.xml

Lines changed: 183 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeSql/Internal/CommonProvider/AdoProvider/AdoProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public abstract partial class AdoProvider : IAdo, IDisposable
3131
public string[] SlaveConnectionStrings { get; protected set; }
3232
public Guid Identifier { get; protected set; }
3333

34-
protected CommonUtils _util { get; set; }
34+
public CommonUtils _util { get; set; }
3535
protected int slaveUnavailables = 0;
3636
private object slaveLock = new object();
3737
private Random slaveRandom = new Random();

0 commit comments

Comments
 (0)