ExternalReferenceAttribute 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 an association references entities belonging to an external DomainContext.


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

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

The ExternalReferenceAttribute type exposes the following members.

Public methodExternalReferenceAttributeInitializes a new instance of the ExternalReferenceAttribute class.

Public propertyTypeId (Inherited from Attribute.)

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.)

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.)

When applied to an entity association member, this attribute indicates that the framework should not create a corresponding EntitySet in the generated client-side code. Consumers of the client-side property will need to add a DomainContext reference to the appropriate DomainContext containing the external entity type.

For a complete example, see Walkthrough: Sharing Entities between Multiple Domain Services.

The following example shows an ExternalReference attribute applied to a member that defines a related entity from another domain service.

using System;
using System.ServiceModel.DomainServices;
using System.ComponentModel.DataAnnotations;

namespace SharedEntityExample.Web
    public partial class SalesOrderHeader
        [Association("Sales_Customer", "CustomerID", "CustomerID")]
        public Customer Customer { get; set; }

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.