Export (0) Print
Expand All

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

Indicates that a member represents an association that is part of a compositional hierarchy.

System.Object
  System.Attribute
    System.ComponentModel.DataAnnotations.CompositionAttribute

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

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

The CompositionAttribute type exposes the following members.

  NameDescription
Public methodCompositionAttributeInitializes a new instance of the CompositionAttribute class.
Top

  NameDescription
Public propertyTypeId (Inherited from Attribute.)
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

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.

The following example shows how to define a compositional relationship between SalesOrderHeader and SalesOrderDetail by using a metadata class.

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

        [Include]
        [Composition]
        public EntitySet<SalesOrderDetail> 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