EntityRef<TEntity>.SetEntity 方法
设置对此EntityRef<TEntity>所指的实体。
命名空间: Microsoft.SharePoint.Linq
程序集: Microsoft.SharePoint.Linq(位于 Microsoft.SharePoint.Linq.dll 中)
语法
声明
Public Sub SetEntity ( _
entity As TEntity _
)
用法
Dim instance As EntityRef
Dim entity As TEntity
instance.SetEntity(entity)
public void SetEntity(
TEntity entity
)
参数
entity
类型:TEntityEntityRef<TEntity>所指向的实体。
备注
与set包装专用EntityRef<TEntity>字段的属性的访问器中调用此方法,属性将能够编写的标准编写语法属性被分配的对象的类型,而不是类型EntityRef<TEntity>,其中 T 是该属性 (和专用的EntityRef<TEntity>字段的类型参数) 的类型时的属性。
SetEntity(TEntity)将值写入字段和它然后写入值后调用OnChanging处理程序之前调用OnChanging处理程序。
示例
下面的代码演示在使用GetEntity() :
[ContentType(Name="Item", Id="0x01", List="Clients")]
public partial class ClientsItem : Item
}
private EntityRef<SalesStaff> _clientRepresentative;
[Association(Name="ClientRepresentative", Storage="_city", MultivalueType=AssociationType.Single, List="Sales Staff")]
public SalesStaff ClientRepresentative {
get {
return this._clientRepresentative.GetEntity();
}
set {
this._clientRepresentative.SetEntity(value);
}
}
// Other members omitted for readability.
}
<ContentType(Name:="Item", Id:="0x01", List:="Clients")>
Partial Public Class ClientsItem
Inherits Item
Private _clientRepresentative As EntityRef(Of SalesStaff)
<Association(Name:="ClientRepresentative", Storage:="_city", MultivalueType:=AssociationType.Single, List:="Sales Staff")>
Public Property ClientRepresentative() As SalesStaff
Get
Return Me._clientRepresentative.GetEntity()
End Get
Set(ByVal value As SalesStaff)
Me._clientRepresentative.SetEntity(value)
End Set
End Property
' Other members omitted for readability.
End Class