Skip to content

Commit

Permalink
- 修复 2.0.103 Uow.Orm 事务 bug;
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Dec 7, 2020
1 parent ff1354d commit 87f2cba
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 10 deletions.
2 changes: 2 additions & 0 deletions FreeSql.DbContext/DbContext/DbContextScopedFreeSql.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public ScopeTransactionAdo(AdoProvider ado, Func<DbTransaction> resolveTran) : b
base.ConnectionString = ado.ConnectionString;
base.SlaveConnectionStrings = ado.SlaveConnectionStrings;
base.Identifier = ado.Identifier;
base.MasterPool = ado.MasterPool;
base._util = ado._util;
}
public override object AddslashesProcessParam(object param, Type mapType, ColumnInfo mapColumn) => _ado.AddslashesProcessParam(param, mapType, mapColumn);
public override DbCommand CreateCommand() => _ado.CreateCommand();
Expand Down
9 changes: 0 additions & 9 deletions FreeSql.DbContext/FreeSql.DbContext.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions FreeSql.Tests/FreeSql.Tests.DbContext/RepositoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,35 @@ class BeginEdit01
public string Name { get; set; }
}

[Fact]
public void OrmScoped()
{
var fsql = g.sqlserver;
//fsql.Aop.CommandBefore += (s, e) =>
//{
// Console.WriteLine(e.Command.CommandText);
//};

var repo = fsql.GetRepository<ts_repo_update_bit>();
repo.Orm.Ado.ExecuteNonQuery("select 1");

using (var ctx = fsql.CreateDbContext())
{
ctx.Orm.Ado.ExecuteNonQuery("select 1");
}

using (var uow = fsql.CreateUnitOfWork())
{
uow.Orm.Ado.ExecuteNonQuery("select 1");
}

using (var uow = fsql.CreateUnitOfWork())
{
repo.UnitOfWork = uow;
repo.Orm.Ado.ExecuteNonQuery("select 1");
}
}

[Fact]
public void UpdateBit()
{
Expand Down
183 changes: 183 additions & 0 deletions FreeSql/FreeSql.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion FreeSql/Internal/CommonProvider/AdoProvider/AdoProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract partial class AdoProvider : IAdo, IDisposable
public string[] SlaveConnectionStrings { get; protected set; }
public Guid Identifier { get; protected set; }

protected CommonUtils _util { get; set; }
public CommonUtils _util { get; set; }
protected int slaveUnavailables = 0;
private object slaveLock = new object();
private Random slaveRandom = new Random();
Expand Down

0 comments on commit 87f2cba

Please sign in to comment.