Export (0) Print
Expand All

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

Specifies that the association should be part of any code-generated client entities.

System.Object
  System.Attribute
    System.ServiceModel.DomainServices.Server.IncludeAttribute

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

[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = true, 
	Inherited = true)]
public sealed class IncludeAttribute : Attribute

The IncludeAttribute type exposes the following members.

  NameDescription
Public methodIncludeAttribute()Initializes a new instance of the IncludeAttribute class.
Public methodIncludeAttribute(String, String)Initializes a new instance of the IncludeAttribute class with the specified member projection.
Top

  NameDescription
Public propertyIsProjectionGets a value that indicates whether this attribute specifies a member projection.
Public propertyMemberNameGets the name of the destination member for the projection.
Public propertyPathGets the member projection path.
Public propertyTypeIdGets a unique identifier for this attribute. (Overrides Attribute.TypeId.)
Top

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

  NameDescription
Explicit interface implemetationPrivate method_Attribute.GetIDsOfNames (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.GetTypeInfo (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.GetTypeInfoCount (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.Invoke (Inherited from Attribute.)
Top

When applied to an entity association, this attribute specifies that the association should be part of any code-generated client entities, and that any related entities should be included when serializing results to the client. In the query method, you must ensure that the associated entities are actually loaded by using the Include method on the query. This attribute can also be used to specify member projections.

The following example shows the IncludeAttribute attribute applied to a member that is part of a hierarchy.

[MetadataTypeAttribute(typeof(SalesOrderHeader.SalesOrderHeaderMetadata))]
public partial class SalesOrderHeader
{
    internal sealed class SalesOrderHeaderMetadata
    {
        private SalesOrderHeaderMetadata()
        {
        }

        [Include]
        [Composition]
        public EntitySet<SalesOrderDetail> SalesOrderDetails;

    }
}


The following example shows how to include the results in the query.

public IQueryable<SalesOrderHeader> GetSalesOrders()
{
    return this.ObjectContext.SalesOrderHeaders.Include("SalesOrderDetails");
}


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:
© 2014 Microsoft