IDataServiceActionProvider.AdvertiseServiceAction Method

Determines if a service action is available for a specific resource.

Namespace:  System.Data.Services.Providers
Assembly:  Microsoft.Data.Services (in Microsoft.Data.Services.dll)

Syntax

'Declaration
Function AdvertiseServiceAction ( _
    operationContext As DataServiceOperationContext, _
    serviceAction As ServiceAction, _
    resourceInstance As Object, _
    resourceInstanceInFeed As Boolean, _
    ByRef actionToSerialize As ODataAction _
) As Boolean
'Usage
Dim instance As IDataServiceActionProvider 
Dim operationContext As DataServiceOperationContext 
Dim serviceAction As ServiceAction 
Dim resourceInstance As Object 
Dim resourceInstanceInFeed As Boolean 
Dim actionToSerialize As ODataAction 
Dim returnValue As Boolean 

returnValue = instance.AdvertiseServiceAction(operationContext, _
    serviceAction, resourceInstance, _
    resourceInstanceInFeed, actionToSerialize)
bool AdvertiseServiceAction(
    DataServiceOperationContext operationContext,
    ServiceAction serviceAction,
    Object resourceInstance,
    bool resourceInstanceInFeed,
    ref ODataAction actionToSerialize
)
bool AdvertiseServiceAction(
    DataServiceOperationContext^ operationContext, 
    ServiceAction^ serviceAction, 
    Object^ resourceInstance, 
    bool resourceInstanceInFeed, 
    ODataAction^% actionToSerialize
)
abstract AdvertiseServiceAction : 
        operationContext:DataServiceOperationContext * 
        serviceAction:ServiceAction * 
        resourceInstance:Object * 
        resourceInstanceInFeed:bool * 
        actionToSerialize:ODataAction byref -> bool
function AdvertiseServiceAction(
    operationContext : DataServiceOperationContext, 
    serviceAction : ServiceAction, 
    resourceInstance : Object, 
    resourceInstanceInFeed : boolean, 
    actionToSerialize : ODataAction
) : boolean

Parameters

  • resourceInstance
    Type: System.Object
    The instance of the resource for which the action availability is being checked.
  • resourceInstanceInFeed
    Type: System.Boolean
    true if the resource instance to be returned is part of a feed; otherwise, false. true indicates that this method will be called multiple times while processing the request since it is called once for every resource returned for the request. If determining whether a service action should be advertised is time-consuming, the provider may choose to always advertise in order to optimize for performance.
  • actionToSerialize
    Type: Microsoft.Data.OData.ODataAction%
    The ODataAction instance that represents the service action to advertise. This is a reference parameter so your implementation may over-write the ODataAction instance passed to this method. This should never be set to nulla null reference (Nothing in Visual Basic) unless returning false.

Return Value

Type: System.Boolean
true if the service action should be advertised; otherwise, false.

Remarks

This method allows you to specify if a service action is bindable for a specific resource. This means the action can be applied to the resource. This method is called for each resource returned for a request. Actions are advertised by adding information in the response based on the format of the response. In the default OData format an action element is added to the response:

<m:action metadata=https://localhost/MyDataService/Service.svc/$metadata#SouponContext.Buy title=”Buy” target=https://localhost/MyDataService/Service/svc/Soupons(1)/Buy xmlns:m=https://schemas.microsoft.com/ado/2007/08/dataservices/metadata />

In the JSON format a URL for the service action is included in the response:

https://localhost/MyDataService/Service.svc/$metadata#SouponContext.Buy

See Also

Reference

IDataServiceActionProvider Interface

System.Data.Services.Providers Namespace