CompositionAttribute 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.]
Indicates that a member represents an association that is part of a compositional hierarchy.
Inheritance Hierarchy
System.Object
System.Attribute
System.ComponentModel.DataAnnotations.CompositionAttribute
Namespace: System.ComponentModel.DataAnnotations
Assembly: System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)
Syntax
'Declaration
<AttributeUsageAttribute(AttributeTargets.Property Or AttributeTargets.Field, AllowMultiple := False, _
Inherited := True)> _
Public NotInheritable Class CompositionAttribute _
Inherits Attribute
'Usage
Dim instance As CompositionAttribute
[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false,
Inherited = true)]
public sealed class CompositionAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Property|AttributeTargets::Field, AllowMultiple = false,
Inherited = true)]
public ref class CompositionAttribute sealed : public Attribute
[<SealedAttribute>]
[<AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false,
Inherited = true)>]
type CompositionAttribute =
class
inherit Attribute
end
public final class CompositionAttribute extends Attribute
The CompositionAttribute type exposes the following members.
Constructors
Name | Description | |
---|---|---|
CompositionAttribute | Initializes a new instance of the CompositionAttribute class. |
Top
Properties
Name | Description | |
---|---|---|
TypeId | (Inherited from Attribute.) |
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
You apply the CompositionAttribute to a property that represents an association between two entities that are conceptually part of a hierarchy, such as a SalesOrderHeader entity and a SalesOrderDetail entity. These related entities are known as a compositional hierarchy. After defining the compositional hierarchy between the classes, you can perform data modification operations on the entities as a single unit instead of as separate entities. This simplifies middle-tier logic because you can write application logic for the entire hierarchy instead of splitting that logic into each entity and attempting to coordinate that split logic during data operations. For more information, see Compositional Hierarchies.
Examples
The following example shows how to define a compositional relationship between SalesOrderHeader and SalesOrderDetail by using a metadata class.
<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;
}
}
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.