InvokeAttribute 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 a DomainService method is an invoke operation.


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

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

The InvokeAttribute type exposes the following members.

Public methodInvokeAttributeInitializes a new instance of the InvokeAttribute class.

Public propertyHasSideEffectsGets or sets a value that indicates whether the invoke operation has side effects.
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.)

You apply the InvokeAttribute attribute to a method to indicate that the method is an invoke method, or to specify certain values for the invoke method. If your method matches the expected method signature for an invoke method, you do not have to apply the InvokeAttribute. The WCF RIA Services framework will infer that a method with the expected invoke signature should be treated as an invoke operation. You apply the IgnoreAttribute to a method to prevent the RIA Services framework from generating a domain operation for that method.

An invoke operation is an operation that needs to be executed without tracking or deferred execution. You should use it only with non-entity data, and only when query, update, insert, or delete operations cannot be used instead. In almost all scenarios, you should use query operations instead of invoke operations to load data. Query methods return either a single Entity object, an IQueryable<Entity> object, or an IEnumerable<Entity> object. Query methods are an integral part of the data pattern supported by DomainService on the middle tier and by DomainContext on the client. The RIA Services framework generates entities in the client project for only those entities that are returned from query methods in a DomainService. Even when an invoke operation returns an entity, the entity is generated for the client project only if it is returned by a query method.

The following shows the expected signature for an invoke method:

Return value




Name Prefix



[Invoke] (C#)


<Invoke> (Visual Basic)



public decimal GetCompetitorsPrice(Product product) (C#)


<Invoke> _

Public GetCompetitorsPrice(ByVal product As Product) As Decimal (Visual Basic)

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