Persists the changes on a single persistent object, an
ObjectSet and
a class that implements the
ICustomPersister interface.
Syntax
| Visual Basic (Usage) | Copy Code |
|---|
Dim instance As ObjectContext
Dim obj As T
Dim persistDepth As PersistDepths
instance.PersistChanges(Of T)(obj, persistDepth)
|
Parameters
- obj
- Persistent object, ObjectSet or class that implements
the ICustomPersister interface that is persisted.
- persistDepth
- Specifies the depth of the object graph that is persisted.
Type Parameters
- T
Exceptions
| Exception | Description |
| ConstraintException | A mandatory property of one persistent object returned Null. |
| ConcurrencyException | Somebody else changed the object in the storage
while it has been in memory. |
| StorageException | Indicates a problem with the storage. All derived exception
may also be thrown. |
Example
The following example shows you how to persist a single persistent object.
| C# | Copy Code |
|---|
// Creates a new ObjectContext that uses an MsSql Server as storage. ObjectContext context = new ObjectContext(new MsSqlStorage("sa", "", "localhost", "application")); // ... Other code. // Get the first user matching the name. User user = context.GetObject<User>("Name like {0}", "%mith%"); // Changes the name property. user.Name = "new Name"; // Persists the user object. context.PersistChanges(user); |
Remarks
Requirements
Platforms: Windows 2000, Windows XP family, Windows Server 2003 family, Windows Vista family
See Also