EntityRef<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 reference to an associated entity.

System.Object
  System.ServiceModel.DomainServices.Client.EntityRef<TEntity>

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

public sealed class EntityRef<TEntity>
where TEntity : Entity

Type Parameters

TEntity

The type of the associated Entity.

The EntityRef<TEntity> type exposes the following members.

  NameDescription
Public methodEntityRef<TEntity>Initializes an instance of the EntityRef<TEntity> class.
Top

  NameDescription
Public propertyEntityGets or sets the associated Entity.
Top

  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Top

public Employee Employee2
{
    get
    {
        if ((this._employee2 == null))
        {
            // Set this._employee2 equal to a new EntityRef of Type Employee.
            this._employee2 = new EntityRef<Employee>(this, "Employee2", this.FilterEmployee2);
        }
        return this._employee2.Entity;
    }
    set
    {
        Employee previous = this.Employee2;
        if ((previous != value))
        {
            this.ValidateProperty("Employee2", value);
            // EntityCollection.Remove()
            if ((previous != null))
            {
                this._employee2.Entity = null;
                previous.Employee1.Remove(this);
                this.Employee1.EntityRemoved += new EventHandler<EntityCollectionChangedEventArgs<Employee>>(Employee1_EntityRemoved);
            }
            if ((value != null))
            {
                this.ManagerID = value.EmployeeID;
            }
            else
            {
                this.ManagerID = default(Nullable<int>);
            }
            this._employee2.Entity = value;
            // EntityCollection.Add()
            if ((value != null))
            {
                value.Employee1.Add(this);
                this.Employee1.EntityAdded += new EventHandler<EntityCollectionChangedEventArgs<Employee>>(Employee1_EntityAdded);

            }
            this.RaisePropertyChanged("Employee2");
        }
    }
}


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: