mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-08-23 13:06:48 +08:00
Routine Update
This commit is contained in:
parent
3170191db6
commit
02ef43c0d1
@ -88,7 +88,7 @@ namespace OpenAuth.App
|
||||
|
||||
public void ModifyOrg(Org org)
|
||||
{
|
||||
_repository.Update(u =>u.Id == org.Id,org);
|
||||
_repository.Update(org);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -31,6 +31,9 @@ namespace OpenAuth.Domain.Interface
|
||||
|
||||
void Add(T entity);
|
||||
|
||||
/// <summary>
|
||||
/// 更新一个实体的所有属性
|
||||
/// </summary>
|
||||
void Update(T entity);
|
||||
|
||||
void Delete(T entity);
|
||||
|
@ -25,8 +25,7 @@
|
||||
showToolbar: true,
|
||||
toolbarItem: 'refresh, |, del,edit',
|
||||
toolbarCustom: '<a href="/OrgManager/AddOrg" class="btn btn-green" data-icon ="plus" ' +
|
||||
'data-toggle="dialog" data-id="dialog-mask" data-mask="true">添加</a>' +
|
||||
'<button class=" btn-green" onclick="editOrg()" data-icon="pencil" type="button">编辑</button>',
|
||||
'data-toggle="dialog" data-id="dialog-mask" data-mask="true">添加</a>' ,
|
||||
columns: [
|
||||
{
|
||||
name: 'Id',
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -125,5 +125,17 @@ namespace OpenAuth.UnitTest
|
||||
Console.WriteLine(org.Name);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestEdit()
|
||||
{
|
||||
var org = new Org
|
||||
{
|
||||
Id = 60,
|
||||
Name = "test"
|
||||
|
||||
};
|
||||
_app.ModifyOrg(org);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user