Persists the changes on a single persistent object, an
ObjectSet and
a class that implements the
ICustomPersister interface.
Syntax
| Visual Basic (Declaration) | |
|---|
Overloads Public Overridable Sub PersistChanges(Of T)( _
ByVal obj As T _
) |
| Visual Basic (Usage) | Copy Code |
|---|
Dim instance As ObjectContext
Dim obj As T
instance.PersistChanges(Of T)(obj)
|
| C# | |
|---|
public virtual void PersistChanges<T>(
T obj
) |
| Managed Extensions for C++ | |
|---|
public: virtual void PersistChanges<T>(
T obj
) |
| C++/CLI | |
|---|
public:
virtual void PersistChangesgeneric<typename T>
(
T obj
) |
Parameters
- obj
- Persistent object, ObjectSet or class that implements
the ICustomPersister interface 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