check bugs

This commit is contained in:
yubaolee@163.com 2018-05-07 14:47:16 +08:00
parent 37a371a138
commit ebf037f518
5 changed files with 170 additions and 154 deletions

View File

@ -436,7 +436,7 @@ namespace OpenAuth.App
public void Update(FlowInstance flowScheme)
{
Repository.Update(u => u.Id == flowScheme.Id, u => new FlowInstance());
Repository.Update(flowScheme);
}
public TableData Load(QueryFlowInstanceListReq request)

View File

@ -30,7 +30,7 @@ namespace OpenAuth.Repository
}
/// <summary>
/// 查找单个
/// 查找单个,且不被上下文所跟踪
/// </summary>
public T FindSingle(Expression<Func<T, bool>> exp)
{
@ -87,9 +87,14 @@ namespace OpenAuth.Repository
public void Update(T entity)
{
var entry = this.Context.Entry(entity);
//todo:如果状态没有任何更改,会报错
entry.State = EntityState.Modified;
//如果数据没有发生变化
if (!this.Context.ChangeTracker.HasChanges())
{
return;
}
Save();
}

View File

@ -19,9 +19,13 @@ namespace OpenAuth.Repository
{
Database.SetInitializer< OpenAuthDBContext>(null);
}
public OpenAuthDBContext()
:base("Name=OpenAuthDBContext")
{ }
: base("Name=OpenAuthDBContext")
{
// 关闭语义可空判断
Configuration.UseDatabaseNullSemantics = true;
}
public OpenAuthDBContext(string nameOrConnectionString)
: base(nameOrConnectionString)

View File

@ -49,5 +49,12 @@ namespace OpenAuth.UnitTest
Console.WriteLine(JsonHelper.Instance.Serialize(result.Result.FrmPreviewHtml));
}
[TestMethod]
public void TestUpdate()
{ //测试数据没有任何修改时EF报错的问题
var instance = _runApp.Get("d73e4412-9c49-4511-a30e-0d2f844afcee");
_runApp.Update(instance);
}
}
}