在控制器,我请执行下列操作:ASP.NET MVC:从模型内更新模型?
DBContext DB = new DBContext();
var u = DB.Users.Find(1);
u.firstname = "blah";
UpdateModel(u);
DB.SaveChanges();
我想从一个模型中做同样的...
namespace Project.Models
{
public class User
{
public void resetPassword()
{
// Generate new password, etc.
this.password = "blah";
}
}
}
任何想法,我怎么会去这样做?看来UpdateModel()
只能在控制器内使用。
我使用的是EntityFramework Code-First CTP5。
你在这里使用UpdateModel()来实现与DB有关的什么? – 2011-02-28 08:07:35