Chili.Opf3 Send comments on this topic.
MarkForDeletion Method
See Also  Example
Chili.Opf3 Namespace > ObjectContext Class : MarkForDeletion Method




obj
Persistent object that is marked for deletion.
Marks a persistent object for deletion.

Syntax

Visual Basic (Declaration) 
Public Sub MarkForDeletion( _
   ByVal obj As Object _
) 
Visual Basic (Usage)Copy Code
Dim instance As ObjectContext
Dim obj As Object
 
instance.MarkForDeletion(obj)
C# 
public void MarkForDeletion( 
   object obj
)
Managed Extensions for C++ 
public: void MarkForDeletion( 
   Object* obj
) 
C++/CLI 
public:
void MarkForDeletion( 
   Object^ obj
) 

Parameters

obj
Persistent object that is marked for deletion.

Example

The following example shows you how delete an object from the storage.
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%"); 
  
// Mark the object for deletion. 
context.MarkForDeletion(user); 
  
// Deletes the user object from the storage. 
context.PersistChanges(user); 
    

Remarks

This routine marks a persistent object for deletion. The object is not deleted immediately. It is deleted on the next call of PersistChanges. If you want to delete immediately an object from the storage you have to mark it for deletion and then call PersistChanges.

Requirements

Platforms: Windows 2000, Windows XP family, Windows Server 2003 family, Windows Vista family

See Also