Share via


EntityCollection<TEntity> Constructor (Entity, String, Func<TEntity, Boolean>, Action<TEntity>, Action<TEntity>)

[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.]

Initializes a new instance of the EntityCollection<TEntity> class with the specified parent, name of the collection on the parent, and functions for filtering, attaching, and detaching.

Namespace:  System.ServiceModel.DomainServices.Client
Assembly:  System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)

Syntax

'Declaration
Public Sub New ( _
    parent As Entity, _
    memberName As String, _
    entityPredicate As Func(Of TEntity, Boolean), _
    attachAction As Action(Of TEntity), _
    detachAction As Action(Of TEntity) _
)
'Usage
Dim parent As Entity
Dim memberName As String
Dim entityPredicate As Func(Of TEntity, Boolean)
Dim attachAction As Action(Of TEntity)
Dim detachAction As Action(Of TEntity)

Dim instance As New EntityCollection(parent, _
    memberName, entityPredicate, attachAction, _
    detachAction)
public EntityCollection(
    Entity parent,
    string memberName,
    Func<TEntity, bool> entityPredicate,
    Action<TEntity> attachAction,
    Action<TEntity> detachAction
)
public:
EntityCollection(
    Entity^ parent, 
    String^ memberName, 
    Func<TEntity, bool>^ entityPredicate, 
    Action<TEntity>^ attachAction, 
    Action<TEntity>^ detachAction
)
new : 
        parent:Entity * 
        memberName:string * 
        entityPredicate:Func<'TEntity, bool> * 
        attachAction:Action<'TEntity> * 
        detachAction:Action<'TEntity> -> EntityCollection
public function EntityCollection(
    parent : Entity, 
    memberName : String, 
    entityPredicate : Func<TEntity, boolean>, 
    attachAction : Action<TEntity>, 
    detachAction : Action<TEntity>
)

Parameters

  • entityPredicate
    Type: System.Func<TEntity, Boolean>
    The function used to filter the associated entities and determine which entities are members of this collection.
  • attachAction
    Type: System.Action<TEntity>
    The function used to establish a back reference from an associated entity to the parent entity.
  • detachAction
    Type: System.Action<TEntity>
    The function used to remove the back reference from an associated entity to the parent entity.

Exceptions

Exception Condition
[ArgumentNullException]

parent, memberName, entityPredicate, attachAction, or detachAction is nulla null reference (Nothing in Visual Basic).

Examples

<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
[Association("Employee_Employee", "EmployeeID", "ManagerID")]
[XmlIgnore()]
public EntityCollection<Employee> Employee1
{
    get
    {
        if ((this._employee1 == null))
        {
            this._employee1 = new EntityCollection<Employee>(this, "Employee1", this.FilterEmployee1, this.AttachEmployee1, this.DetachEmployee1);
        }
        return this._employee1;
    }
}

See Also

Reference

EntityCollection<TEntity> Class

EntityCollection<TEntity> Overload

System.ServiceModel.DomainServices.Client Namespace