IncludeAttribute Class
[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.
Inheritance Hierarchy
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)
Syntax
'Declaration
<AttributeUsageAttribute(AttributeTargets.Property Or AttributeTargets.Field, AllowMultiple := True, _
Inherited := True)> _
Public NotInheritable Class IncludeAttribute _
Inherits Attribute
'Usage
Dim instance As IncludeAttribute
[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = true,
Inherited = true)]
public sealed class IncludeAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Property|AttributeTargets::Field, AllowMultiple = true,
Inherited = true)]
public ref class IncludeAttribute sealed : public Attribute
[<SealedAttribute>]
[<AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = true,
Inherited = true)>]
type IncludeAttribute =
class
inherit Attribute
end
public final class IncludeAttribute extends Attribute
The IncludeAttribute type exposes the following members.
Constructors
Name | Description | |
---|---|---|
IncludeAttribute() | Initializes a new instance of the IncludeAttribute class. | |
IncludeAttribute(String, String) | Initializes a new instance of the IncludeAttribute class with the specified member projection. |
Top
Properties
Name | Description | |
---|---|---|
IsProjection | Gets a value that indicates whether this attribute specifies a member projection. | |
MemberName | Gets the name of the destination member for the projection. | |
Path | Gets the member projection path. | |
TypeId | Gets a unique identifier for this attribute. (Overrides Attribute.TypeId.) |
Top
Methods
Name | Description | |
---|---|---|
Equals | (Inherited from Attribute.) | |
Finalize | (Inherited from Object.) | |
GetHashCode | (Inherited from Attribute.) | |
GetType | (Inherited from Object.) | |
IsDefaultAttribute | (Inherited from Attribute.) | |
Match | (Inherited from Attribute.) | |
MemberwiseClone | (Inherited from Object.) | |
ToString | (Inherited from Object.) |
Top
Explicit Interface Implementations
Name | Description | |
---|---|---|
_Attribute.GetIDsOfNames | (Inherited from Attribute.) | |
_Attribute.GetTypeInfo | (Inherited from Attribute.) | |
_Attribute.GetTypeInfoCount | (Inherited from Attribute.) | |
_Attribute.Invoke | (Inherited from Attribute.) |
Top
Remarks
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.
Examples
The following example shows the IncludeAttribute attribute applied to a member that is part of a hierarchy.
<MetadataTypeAttribute(GetType(SalesOrderHeader.SalesOrderHeaderMetadata))> _
Partial Public Class SalesOrderHeader
Friend NotInheritable Class SalesOrderHeaderMetadata
Private Sub New()
MyBase.New
End Sub
<Include()> _
<Composition()> _
Public SalesOrderDetails As EntityCollection(Of SalesOrderDetail)
End Class
End Class
[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 Function GetSalesOrders() As IQueryable(Of SalesOrderHeader)
Return Me.ObjectContext.SalesOrderHeaders.Include("SalesOrderDetails")
End Function
public IQueryable<SalesOrderHeader> GetSalesOrders()
{
return this.ObjectContext.SalesOrderHeaders.Include("SalesOrderDetails");
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.