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

Inheritance Hierarchy


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


<AttributeUsageAttribute(AttributeTargets.Method Or AttributeTargets.Property Or AttributeTargets.Field, AllowMultiple := False,  _
    Inherited := True)> _
Public NotInheritable Class InvokeAttribute _
    Inherits Attribute
Dim instance As InvokeAttribute
[AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false, 
    Inherited = true)]
public sealed class InvokeAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Method|AttributeTargets::Property|AttributeTargets::Field, AllowMultiple = false, 
    Inherited = true)]
public ref class InvokeAttribute sealed : public Attribute
[<AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false, 
    Inherited = true)>]
type InvokeAttribute =  
        inherit Attribute
public final class InvokeAttribute extends Attribute

The InvokeAttribute type exposes the following members.


Name Description
Public method InvokeAttribute Initializes a new instance of the InvokeAttribute class.



Name Description
Public property HasSideEffects Gets or sets a value that indicates whether the invoke operation has side effects.
Public property TypeId (Inherited from Attribute.)



Name Description
Public method Equals (Inherited from Attribute.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Attribute.)
Public method GetType (Inherited from Object.)
Public method IsDefaultAttribute (Inherited from Attribute.)
Public method Match (Inherited from Attribute.)
Protected method MemberwiseClone (Inherited from Object.)
Public method ToString (Inherited from Object.)


Explicit Interface Implementations

Name Description
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)

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.

See Also


System.ServiceModel.DomainServices.Server Namespace