EntityList<TEntity>.DeleteOnSubmit 方法

将标记为SubmitChanges()的下一次调用删除指定的实体。

命名空间:  Microsoft.SharePoint.Linq
程序集:  Microsoft.SharePoint.Linq(位于 Microsoft.SharePoint.Linq.dll 中)

语法

声明
Public Sub DeleteOnSubmit ( _
    entity As TEntity _
)
用法
Dim instance As EntityList
Dim entity As TEntity

instance.DeleteOnSubmit(entity)
public void DeleteOnSubmit(
    TEntity entity
)

参数

  • entity
    类型:TEntity

    要将标记为删除的实体。

异常

异常 条件
ArgumentNullException

entity是空引用(无 在 Visual Basic 中)。

InvalidOperationException

DataContext对象未启用跟踪的对象。

- 或者 -

entity不是相同类型的列表项。

备注

entity通常为列表项,但它可以是一个分离的实体列表项类型相同。

示例

以下是在使用DeleteOnSubmit(TEntity)的一个示例:

// 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.

另请参阅

引用

EntityList<TEntity> 类

EntityList<TEntity> 成员

Microsoft.SharePoint.Linq 命名空间

其他资源

How to: Write to the Content Databases Using LINQ to SharePoint