ObjectContext.SaveChanges Method

 

Persists all updates to the store.

Namespace:   System.Data.Entity.Core.Objects
Assembly:  EntityFramework (in EntityFramework.dll)

NameDescription
System_CAPS_pubmethodSaveChanges()

Persists all updates to the database and resets change tracking in the object context.

System_CAPS_pubmethodSaveChanges(Boolean)

Obsolete.Persists all updates to the database and optionally resets change tracking in the object context.

System_CAPS_pubmethodSaveChanges(SaveOptions)

Persists all updates to the database and optionally resets change tracking in the object context.


ObjectContext.SaveChanges Method ()

Persists all updates to the database and resets change tracking in the object context.

public virtual int SaveChanges()

Return Value

Type: System.Int32

The number of objects in an Added, Modified, or Deleted state when SaveChanges was called.

Exception Condition
OptimisticConcurrencyException

An optimistic concurrency violation has occurred while saving changes.


ObjectContext.SaveChanges Method (Boolean)

Note: This API is now obsolete.

Persists all updates to the database and optionally resets change tracking in the object context.

[EditorBrowsableAttribute(EditorBrowsableState.Never)]
[BrowsableAttribute(false)]
[ObsoleteAttribute("Use SaveChanges(SaveOptions options) instead.")]
public virtual int SaveChanges(
	bool acceptChangesDuringSave
)

Parameters

acceptChangesDuringSave
Type: System.Boolean

This parameter is needed for client-side transaction support. If true, the change tracking on all objects is reset after SaveChanges finishes. If false, you must call the AcceptAllChanges method after SaveChanges.

Return Value

Type: System.Int32

The number of objects in an Added, Modified, or Deleted state when SaveChanges was called.

Exception Condition
OptimisticConcurrencyException

An optimistic concurrency violation has occurred while saving changes.


ObjectContext.SaveChanges Method (SaveOptions)

Persists all updates to the database and optionally resets change tracking in the object context.

public virtual int SaveChanges(
	SaveOptions options
)

Parameters

options
Type: System.Data.Entity.Core.Objects.SaveOptions

A SaveOptions value that determines the behavior of the operation.

Return Value

Type: System.Int32

The number of objects in an Added, Modified, or Deleted state when SaveChanges was called.

Exception Condition
OptimisticConcurrencyException

An optimistic concurrency violation has occurred while saving changes.