mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
@ -135,89 +135,6 @@ namespace FreeSql.Tests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnitOfWorkRepositoryWithDisableBeforeInsert()
|
||||
{
|
||||
foreach (var fsql in new[] { g.sqlite, })
|
||||
{
|
||||
fsql.CodeFirst.ConfigEntity<FlowModel>(f =>
|
||||
{
|
||||
f.Property(b => b.UserId).IsPrimary(true);
|
||||
f.Property(b => b.Id).IsPrimary(true).IsIdentity(true);
|
||||
f.Property(b => b.Name).IsNullable(false);
|
||||
});
|
||||
|
||||
var flowRepos = fsql.GetRepository<FlowModel>();
|
||||
|
||||
var flow = new FlowModel()
|
||||
{
|
||||
CreateTime = DateTime.Now,
|
||||
Name = "aaa",
|
||||
LastModifyTime = DateTime.Now,
|
||||
UserId = 1,
|
||||
};
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>Ѵ<EFBFBD><D1B4>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>ݣ<EFBFBD>Ϊ<EFBFBD>˽<EFBFBD><CBBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
flowRepos.Delete(a => a.UserId == 1 && a.Name == "aaa");
|
||||
|
||||
using (var uow = fsql.CreateUnitOfWork())
|
||||
{
|
||||
//<2F>رչ<D8B1><D5B9><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD>Ὺʼ<E1BFAA><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uow.Close();
|
||||
var uowFlowRepos = uow.GetRepository<FlowModel>();
|
||||
uowFlowRepos.Insert(flow);
|
||||
uowFlowRepos.Orm.Select<FlowModel>().ToList();
|
||||
//<2F>ѹرչ<D8B1><D5B9><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>ύ<EFBFBD><E1BDBB>ûӰ<C3BB>죬<EFBFBD>˴<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ر<EFBFBD><D8B1>ˣ<EFBFBD><CBA3><EFBFBD>CommitҲӦ<D2B2>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//uow.Commit();
|
||||
}
|
||||
|
||||
Assert.True(flowRepos.Select.Any(a => a.UserId == 1 && a.Name == "aaa"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnitOfWorkRepositoryWithDisableAfterInsert()
|
||||
{
|
||||
foreach (var fsql in new[] { g.sqlite, })
|
||||
{
|
||||
fsql.CodeFirst.ConfigEntity<FlowModel>(f =>
|
||||
{
|
||||
f.Property(b => b.UserId).IsPrimary(true);
|
||||
f.Property(b => b.Id).IsPrimary(true).IsIdentity(true);
|
||||
f.Property(b => b.Name).IsNullable(false);
|
||||
});
|
||||
|
||||
var flowRepos = fsql.GetRepository<FlowModel>();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>Ѵ<EFBFBD><D1B4>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>ݣ<EFBFBD>Ϊ<EFBFBD>˽<EFBFBD><CBBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
flowRepos.Delete(a => a.UserId == 1 && a.Name == "aaa");
|
||||
|
||||
var flow = new FlowModel()
|
||||
{
|
||||
CreateTime = DateTime.Now,
|
||||
Name = "aaa",
|
||||
LastModifyTime = DateTime.Now,
|
||||
UserId = 1,
|
||||
};
|
||||
|
||||
|
||||
Assert.Throws<Exception>(() =>
|
||||
{
|
||||
using (var uow = fsql.CreateUnitOfWork())
|
||||
{
|
||||
var uowFlowRepos = uow.GetRepository<FlowModel>();
|
||||
uowFlowRepos.Insert(flow);
|
||||
uowFlowRepos.Orm.Select<FlowModel>().ToList();
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Insert/Update/Delete <20><><EFBFBD>ùر<C3B9>uow<6F>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᷢ<EFBFBD><E1B7A2><EFBFBD>쳣
|
||||
uow.Close();
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnitOfWorkRepositoryWithoutDisable()
|
||||
{
|
||||
|
Reference in New Issue
Block a user