Export (0) Print
Expand All

ObjectContext.SaveChanges Method (SaveOptions)

Persists all updates to the data source with the specified SaveOptions.

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

abstract SaveChanges : 
        options:SaveOptions -> int 
override SaveChanges : 
        options:SaveOptions -> int 

Parameters

options
Type: System.Data.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.

ExceptionCondition
OptimisticConcurrencyException

An optimistic concurrency violation has occurred.

Use this specific overload of SaveChanges to either make sure that DetectChanges is called before you save changes to the data source or that AcceptAllChanges is called after you save changes to the data source.

This enumeration has a FlagsAttribute that allows for a bitwise combination of its member values.

To make sure that objects on the client have been updated by data source-side logic, you can call the Refresh method with the StoreWins value after you call SaveChanges. The SaveChanges method operates in a transaction. SaveChanges will roll back that transaction and throw an exception if any one of the dirty ObjectStateEntry objects cannot be persisted.

If an optimistic concurrency violation has occurred, an OptimisticConcurrencyException is thrown. You can resolve an optimistic concurrency violation by catching it, calling the Refresh method with the StoreWins or ClientWins values, and then calling the SaveChanges method again. For more information, see How to: Manage Data Concurrency in the Object Context (Entity Framework).

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft