을이 닷넷이 예를 들어
4.0, 우리 가정 할 수 있습니다 Product 객체를 다루고 있습니다.
using (DBEntities context = new DBEntities())
{
//Must attach first and change the state to modified
context.Products.Attach(product);
//If you are using .Net 4.1 then you can use this line instead:
//context.Entry(
context.ObjectStateManager.ChangeObjectState(product, EntityState.Modified);
context.SaveChanges();
}
여기에 본 당신이 당신 대신 "context.ObjectStateManager.ChangeObjectState (제품, EntityState.Modified)"의 "context.Entry (...)"을 사용할 수 있습니다 닷넷 4.1을 사용하는 경우 : Example of context.Entry()
가장 직접적인 방법입니다. 먼저 DB에서 객체를 가져올 필요가 없습니다. 사용자가 수정하려는 객체를 제공하면됩니다. 유일한 단점은이 단일 필드가 아니라 모든 필드를 업데이트한다는 것입니다.
http://blogs.msdn.com/b/wriju/archive/2009/04/24/ado-net-entity-framework-editing-a-detached-object.aspx –