mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 调整 BaseEntity,移除 BaseTreeEntity、Tenant 租户,改变事务习惯;
This commit is contained in:
@ -37,6 +37,8 @@ namespace base_entity
|
||||
public string title { get; set; }
|
||||
}
|
||||
|
||||
static AsyncLocal<IUnitOfWork> _asyncUow = new AsyncLocal<IUnitOfWork>();
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
||||
@ -73,7 +75,7 @@ namespace base_entity
|
||||
.UseMonitorCommand(cmd => Console.Write(cmd.CommandText))
|
||||
.UseLazyLoading(true)
|
||||
.Build();
|
||||
BaseEntity.Initialization(fsql);
|
||||
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
||||
#endregion
|
||||
|
||||
var test01 = EMSServerModel.Model.User.Select.IncludeMany(a => a.Roles).ToList();
|
||||
@ -144,9 +146,17 @@ namespace base_entity
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
using (var uow = BaseEntity.Begin())
|
||||
using (var uow = BaseEntity.Orm.CreateUnitOfWork())
|
||||
{
|
||||
var id = (await new User1().SaveAsync()).Id;
|
||||
_asyncUow.Value = uow;
|
||||
try
|
||||
{
|
||||
var id = (await new User1().SaveAsync()).Id;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_asyncUow.Value = null;
|
||||
}
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user