으로 업데이트하지 않습니다. ApplyCurrentValues 메서드로 10 진수 (19,4) Nullable 필드를 0으로 업데이트하려고하면 필드가 업데이트되지 않고 이전 값을 유지합니다. Zero를 제외한 모든 값이 업데이트됩니다. nullable 특성을 갖는 다른 십진수 필드도 0으로 설정할 수 있습니다.Entity Framework 4 ApplyCurrentValues가 0이 아닌 소수 열을
사용되는 코드는 다음과 같습니다 :
public Int32 saveEntity(tblEntity entity)
{
using (conn)
{
Container _context = new Container();
if (entity.ID != 0)
{
var stub = new tblEntity() { ID = entity.ID };
_context.tblEntitySet.Attach(stub);
_context.tblEntitySet.ApplyCurrentValues(entity);
}
else
{
_context.tblEntitySet.AddObject(entity);
}
_context.SaveChanges();
return entity.ID;
}
}
엔티티에는 항상 ID (기본 키)라는 열이 있습니다. 위의 코드는 예상대로 작동하지만 null이 아닌 십진수 열만 0으로 업데이트되지 않습니다. – serkanz
nullable이 아닌 double 또는 float가 동일한 동작을 생성합니까? –
더블 또는 플로트 타입을 사용하지 않았습니다. 그런데 내가 사용할 때 대신 : var stub = new tblEntity() {ID = entity.ID}; _context.tblEntitySet.Attach (스텁); 사용할 때 : _context.tblEntitySet.Attach (_context.tblEntitySet.Single (s => s.ID == entity.ID)); 모든 것이 예상대로 작동합니다. 그건 그렇고 난. NET Framework 3.5 응용 프로그램에 의해 소비되는 WCF 서비스에서 EF4를 사용합니다. 그래서 우리는 그것이 "disconnected"모드로 작동한다고 말할 수 있습니다. – serkanz