EntityRef<TEntity>.GetEntity method

Returns the entity that is wrapped by this EntityRef<TEntity> object.

Namespace:  Microsoft.SharePoint.Linq
Assembly:  Microsoft.SharePoint.Linq (in Microsoft.SharePoint.Linq.dll)

public TEntity GetEntity()

Return value

Type: TEntity
A Object that represents the entity that is stored in a private field of this EntityRef<TEntity> object.

Calling this method with the get accessor of a property that wraps a private EntityRef<TEntity> field enables the property to be read with standard property reading syntax when the property value is being assigned to an object of type T, rather than type EntityRef<TEntity>, where T is the type of the property (and the type parameter of the private EntityRef<TEntity> field).

The following code shows GetEntity() in use:

[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.
}
Show: