共用方式為


InvokeAttribute 類別

指定 DomainService 方法為叫用作業。

命名空間: System.ServiceModel.DomainServices.Server
組件: System.ServiceModel.DomainServices.Server (於 system.servicemodel.domainservices.server.dll)

使用方式

'用途
Dim instance As InvokeAttribute

語法

'宣告
<AttributeUsageAttribute(AttributeTargets.Method Or AttributeTargets.Property Or AttributeTargets.Field, AllowMultiple:=False, Inherited:=True)> _
Public NotInheritable Class InvokeAttribute
    Inherits Attribute
[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
/** @attribute AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field, AllowMultiple=false, Inherited=true) */ 
public final class InvokeAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field, AllowMultiple=false, Inherited=true) 
public final class InvokeAttribute extends Attribute

備註

您將 InvokeAttribute 屬性套用至方法,即可表示該方法是叫用方法,或是為叫用方法指定特定值。如果您的方法符合叫用方法預期的方法簽章,就不必套用 InvokeAttribute。WCF RIA Services 架構會推斷,具有預期之叫用簽章的方法應該視為叫用作業。您將 IgnoreAttribute 套用至方法,即可避免 RIA Services 架構針對該方法產生網域作業。

叫用作業是指需要執行,但是不追蹤或延後執行的作業。您應該只搭配非實體資料使用該作業,並且只在查詢、更新、插入或刪除作業都無法使用時使用。在絕大多數情況下,您應該使用查詢作業,而不是叫用作業來載入資料。查詢方法會傳回單一 Entity 物件、IQueryable<Entity> 物件或 IEnumerable<Entity> 物件。查詢方法是中介層上的 DomainService 和用戶端上的 DomainContext 所支援資料模式中不可或缺的一部分。RIA Services 架構只會在用戶端專案中針對從 DomainService 中的查詢方法傳回的實體產生實體。即使叫用作業傳回實體,也只有在實體是由查詢方法傳回時,才會針對用戶端專案產生該實體。

以下將示範叫用方法的預期簽章:

傳回值

任何

參數

任何

名稱前置詞

任何

屬性

[Invoke] (C#)

-或-

<Invoke> (Visual Basic)

範例

[Invoke]

public decimal GetCompetitorsPrice(Product product) (C#)

-或-

<Invoke> _

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

繼承階層

System.Object
   System.Attribute
    System.ServiceModel.DomainServices.Server.InvokeAttribute

執行緒安全性

任何這個類型的公用靜態 (在 Visual Basic 中為 共用) 成員都具備執行緒安全。 不保證任何執行個體成員安全執行緒。

平台

開發平台

Windows XP Home Edition, Windows XP Professional, Windows Server 2003 、Windows Server 2008 和 Windows 2000

目標平台

另請參閱

參考

InvokeAttribute 成員
System.ServiceModel.DomainServices.Server 命名空間