EntityCollection(Of TEntity) Class
WCF RIA Services
[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]
Represents a collection of associated entities.
Namespace: System.ServiceModel.DomainServices.Client
Assembly: System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)
'Declaration Public NotInheritable Class EntityCollection(Of TEntity As Entity) _ Implements IEnumerable(Of TEntity), IEnumerable, INotifyCollectionChanged, _ INotifyPropertyChanged, ICollectionViewFactory 'Usage Dim instance As EntityCollection(Of TEntity)
Type Parameters
- TEntity
The type of Entity in the collection.
The EntityCollection(Of TEntity) type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | EntityCollection(Of TEntity)(Entity, String, Func(Of TEntity, Boolean)) | Initializes a new instance of the EntityCollection(Of TEntity) class with the specified parent, name of the collection on the parent, and filter function. |
![]() | EntityCollection(Of TEntity)(Entity, String, Func(Of TEntity, Boolean), Action(Of TEntity), Action(Of TEntity)) | Initializes a new instance of the EntityCollection(Of TEntity) class with the specified parent, name of the collection on the parent, and functions for filtering, attaching, and detaching. |
| Name | Description | |
|---|---|---|
![]() | Add | Adds the specified entity to this collection. |
![]() | Equals | (Inherited from Object.) |
![]() | Finalize | (Inherited from Object.) |
![]() | GetEnumerator | Returns an enumerator for this collection. |
![]() | GetHashCode | (Inherited from Object.) |
![]() | GetType | (Inherited from Object.) |
![]() | MemberwiseClone | (Inherited from Object.) |
![]() | Remove | Removes the specified entity from this collection. |
![]() | ToString | Returns a textual representation of the collection. (Overrides Object.ToString.) |
| Name | Description | |
|---|---|---|
![]() | EntityAdded | Raised when an Entity is added to this collection. |
![]() | EntityRemoved | Raised when an Entity is removed from this collection. |
| Name | Description | |
|---|---|---|
![]() ![]() | INotifyCollectionChanged.CollectionChanged | Raised when the contents of the collection changes. |
![]() ![]() | ICollectionViewFactory.CreateView | Returns a custom view for specialized sorting, filtering, grouping, and currency. |
![]() ![]() | IEnumerable.GetEnumerator | Returns an enumerator for this collection. |
![]() ![]() | INotifyPropertyChanged.PropertyChanged | Raised when a property on this collection changes. |
' <summary> ' Gets the collection of associated <see cref="Employee"/> entity instances. ' </summary> <Association("Employee_Employee", "EmployeeID", "ManagerID")> <XmlIgnore()> Public ReadOnly Property Employee0 As EntityCollection(Of Employee) Get If Me._employee0 = Nothing Then Me._employee0 = New EntityCollection(Of Employee)(Me, "Employee0", Me.FilterEmployee0); End If End Get End Property <Association("Employee_Employee", "EmployeeID", "ManagerID")> <XmlIgnore()> Public ReadOnly Property Employee1 As EntityCollection(Of Employee) Get If Me._employee1 = Nothing Then Me._employee1 = New EntityCollection(Of Employee)(Me, "Employee1", Me.FilterEmployee1, Me.AttachEmployee1, Me.DetachEmployee1); End If End Get End Property ' <summary> ' Gets or sets the associated <see cref="Employee"/> entity. ' </summary> <Association("Employee_Employee", "ManagerID", "EmployeeID", IsForeignKey = True)> <XmlIgnore()> Public Property Employee2 As Employee Get If Me._employee2 = Nothing Then Me._employee2 = New EntityRef(Of Employee)(Me, "Employee2", Me.FilterEmployee2) End If End Get Set(ByVal value As Employee) Dim previous As Employee = Me.Employee2 If previous = Me.Employee2 Then Me.ValidateProperty("Employee2", value) ' EntityCollection.Remove() If previous <> Value Then Me._employee2.Entity = Nothing previous.Employee1.Remove(Me) Me.Employee1.EntityRemoved += New EventHandler(Of EntityCollectionChangedEventArgs(Of Employee))(Employee1_EntityRemoved) End If If Value <> Nothing Then Me.ManagerID = value.EmployeeID End If Me._employee2.Entity = value ' EntityCollection.Add() If value <> Nothing Then value.Employee1.Add(Me) Me.Employee1.EntityAdded += New EventHandler(Of EntityCollectionChangedEventArgs(Of Employee))(Employee1_EntityAdded) End If Me.RaisePropertyChanged("Employee2") End If End Set End Property Public Property Employee1_EntityAdded As EventHandler(Of EntityCollectionChangedEventArgs(Of Employee)) Set(ByVal value As EventHandler(Of EntityCollectionChangedEventArgs(Of Employee))) Me._count = Me.Employee1.Count End Set End Property Public Property Employee1_EntityRemoved As EventHandler(Of EntityCollectionChangedEventArgs(Of Employee)) Set(ByVal value As EventHandler(Of EntityCollectionChangedEventArgs(Of Employee))) Me._count = Me.Employee1.Count End Set End Property Public ReadOnly Property Employee1Enumerator As IEnumerator(Of Employee) Get Return this._employee1Enumerator End Get End Property Private Function AttachEmployee0(ByVal entity As Employee) entity.Employee2 = Me End Function Private Function AttachEmployee1(ByVal entity As Employee) entity.Employee2 = Me End Function Private Function DetachEmployee0(ByVal entity As Employee) entity.Employee2 = Nothing End Function Private Function DetachEmployee1(ByVal entity As Employee) entity.Employee2 = Nothing End Function Private Function FilterEmployee0(ByVal entity As Employee) As Boolean Return (entity.ManagerID = Me.EmployeeID) End Function Private Function FilterEmployee1(ByVal entity As Employee) As Boolean Return (entity.ManagerID = Me.EmployeeID) End Function Private Function FilterEmployee2(ByVal entity As Employee) As Boolean Return (entity.ManagerID = Me.EmployeeID) End Function
Show:

