共用方式為


IgnoreAttribute 類別

指定 DomainService 上的方法不是網域作業。

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

使用方式

'用途
Dim instance As IgnoreAttribute

語法

'宣告
<AttributeUsageAttribute(AttributeTargets.Method Or AttributeTargets.Property Or AttributeTargets.Field, AllowMultiple:=False, Inherited:=True)> _
Public NotInheritable Class IgnoreAttribute
    Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field, AllowMultiple=false, Inherited=true)] 
public sealed class IgnoreAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Method|AttributeTargets::Property|AttributeTargets::Field, AllowMultiple=false, Inherited=true)] 
public ref class IgnoreAttribute sealed : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field, AllowMultiple=false, Inherited=true) */ 
public final class IgnoreAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field, AllowMultiple=false, Inherited=true) 
public final class IgnoreAttribute extends Attribute

範例

下列範例示範網域服務中網域作業所呼叫,但不是公開為網域作業的方法。

Public Sub InsertCustomer(ByVal customer As Customer)
    If (customer.SalesPerson = String.Empty) Then
        customer.SalesPerson = RetrieveSalesPersonForCompany(customer.CompanyName)
    End If

    If ((customer.EntityState = EntityState.Detached) _
                = False) Then
        Me.ObjectContext.ObjectStateManager.ChangeObjectState(customer, EntityState.Added)
    Else
        Me.ObjectContext.Customers.AddObject(customer)
    End If
End Sub

<Ignore()> _
Public Function RetrieveSalesPersonForCompany(ByVal companyname As String) As String
    Dim salesPersonToAssign As String = "unassigned"

    Dim customers As List(Of Customer)
    customers = GetCustomers().Where(Function(c) c.CompanyName = companyname).ToList()

    If (customers.Count > 0) Then
        salesPersonToAssign = customers.First().SalesPerson
    End If

    Return salesPersonToAssign
End Function
public void InsertCustomer(Customer customer)
{
    if (customer.SalesPerson == String.Empty)
    {
        customer.SalesPerson = RetrieveSalesPersonForCompany(customer.CompanyName);
    }

    if ((customer.EntityState != EntityState.Detached))
    {
        this.ObjectContext.ObjectStateManager.ChangeObjectState(customer, EntityState.Added);
    }
    else
    {
        this.ObjectContext.Customers.AddObject(customer);
    }
}

[Ignore]
public string RetrieveSalesPersonForCompany(string companyname)
{
    string salesPersonToAssign = "unassigned";

    List<Customer> customers = GetCustomers().Where(c => c.CompanyName == companyname).ToList();
    if (customers.Count > 0)
    {
        salesPersonToAssign = customers.First().SalesPerson;
    }

    return salesPersonToAssign;
}

備註

使用 IgnoreAttribute 屬性可確保不會將網域服務上的方法公開為網域作業。

繼承階層

System.Object
   System.Attribute
    System.ServiceModel.DomainServices.Server.IgnoreAttribute

執行緒安全性

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

平台

開發平台

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

目標平台

Change History

另請參閱

參考

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