EntityList<TEntity>.DeleteOnSubmit Method
Marks the specified entity for deletion on the next call of SubmitChanges().
Namespace: Microsoft.SharePoint.Linq
Assembly: Microsoft.SharePoint.Linq (in Microsoft.SharePoint.Linq.dll)
Syntax
'Declaration
Public Sub DeleteOnSubmit ( _
entity As TEntity _
)
'Usage
Dim instance As EntityList
Dim entity As TEntity
instance.DeleteOnSubmit(entity)
public void DeleteOnSubmit(
TEntity entity
)
Parameters
entity
Type: TEntityThe entity to be marked for deletion.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | entity is a null reference (Nothing in Visual Basic). |
InvalidOperationException | Object tracking is not enabled for the DataContext object. - or - entity is not of the same type as the list items. |
Remarks
entity is usually a list item, but it can be a detached entity of the same type as the list items.
Examples
The following is an example of DeleteOnSubmit(TEntity) in use:
// Set the item to be deleted.
foreach (TeamMember teamMember in teamSite.TeamMembers)
{
if (teamMember.Title = “Bob Smith”)
{
teamSite.TeamMembers.DeleteOnSubmit(teamMember);
}
}
// Write changes to the content database.
teamSite.SubmitChanges();
// Try-catch block omitted for readability.
' Set the item to be deleted.
For Each teamMember As TeamMember In teamSite.TeamMembers
If teamMember.Title = "Bob Smith" Then
teamSite.TeamMembers.DeleteOnSubmit(teamMember)
End If
Next teamMember
' Write changes to the content database.
teamSite.SubmitChanges()
' Try-catch block omitted for readability.
See Also
Reference
Microsoft.SharePoint.Linq Namespace