Sets the state of the persistent object to the given
ObjectStates.
Syntax
| Visual Basic (Declaration) | |
|---|
Public Function SetObjectState( _
ByVal obj As Object, _
ByVal objectState As ObjectStates _
) As Boolean |
| Visual Basic (Usage) | Copy Code |
|---|
Dim instance As ObjectContext
Dim obj As Object
Dim objectState As ObjectStates
Dim value As Boolean
value = instance.SetObjectState(obj, objectState)
|
Parameters
- obj
-
Persistent objects that ObjectStates is changed.
- objectState
- ObjectStates that is set for the given
persistent object.
Example
The following example changes the state of an object.
| C# | Copy Code |
|---|
// Load the object from the storage. User user1 = context.GetObject<User>("Id = {0}", "1"); // Create a new user object. User user2 = new User(); // Copy all properties of the first user object to the second. user2.Name = user1.Name; // ... Other properties. // Set the state of the object as inserted. This means that // the framework will do an update the next time when saving the // object. context.SetObjectState<User>(user2, ObjectStates.Inserted); // Change the object. user2.Name = "new Name"; // Persist the changes. context.PersistChanges(user2); |
Remarks
Requirements
Platforms: Windows 2000, Windows XP family, Windows Server 2003 family, Windows Vista family
See Also