62,025
社区成员
发帖
与我相关
我的任务
分享
public void Update<T>(T model)//T是实体类型
{
using (var context = new EasyWebEntitiesContainer())
{
var type = model.GetType();
var name = type.Name;
context.AttachTo(name, model);
context.ObjectStateManager.GetObjectStateEntry(model).SetModified();//TODO .net4.0 有更好的方法,ApplyCurrentValues
context.SaveChanges();
}
}