Routine Update

This commit is contained in:
yubaolee
2015-11-06 22:56:26 +08:00
parent 3170191db6
commit 02ef43c0d1
5 changed files with 23 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Linq.Expressions;
@@ -61,7 +62,10 @@ namespace OpenAuth.Repository
public void Update(T entity)
{
Context.Set<T>().AddOrUpdate(entity);
var entry = this.Context.Entry(entity);
entry.State = EntityState.Modified;
Save();
}
@@ -73,6 +77,7 @@ namespace OpenAuth.Repository
public void Update(Expression<Func<T, bool>> exp, T entity)
{
//TODO: 暂时有问题EntityFramework.Extension的Update必须有new操作
Context.Set<T>().Where(exp).Update(u => entity);
}