共用方式為


DataObjectAttribute 建構函式

定義

初始化 DataObjectAttribute 類別的新執行個體。

多載

名稱 Description
DataObjectAttribute()

初始化 DataObjectAttribute 類別的新執行個體。

DataObjectAttribute(Boolean)

初始化該類別的新實例 DataObjectAttribute ,並指示物件是否適合綁定到物件 ObjectDataSource

DataObjectAttribute()

來源:
DataObjectAttribute.cs
來源:
DataObjectAttribute.cs
來源:
DataObjectAttribute.cs
來源:
DataObjectAttribute.cs
來源:
DataObjectAttribute.cs

初始化 DataObjectAttribute 類別的新執行個體。

public:
 DataObjectAttribute();
public DataObjectAttribute();
Public Sub New ()

範例

以下程式碼範例示範使用建 DataObjectAttribute() 構子。

[DataObjectAttribute]
public class NorthwindData
{  
  public NorthwindData() {}

  [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
  public static IEnumerable GetAllEmployees()
  {
    AccessDataSource ads = new AccessDataSource();
    ads.DataSourceMode = SqlDataSourceMode.DataReader;
    ads.DataFile = "~//App_Data//Northwind.mdb";
    ads.SelectCommand = "SELECT EmployeeID,FirstName,LastName FROM Employees";
    return ads.Select(DataSourceSelectArguments.Empty);
  }

  // Delete the Employee by ID.
  [DataObjectMethodAttribute(DataObjectMethodType.Delete, true)]
  public void DeleteEmployeeByID(int employeeID)
  {
    throw new Exception("The value passed to the delete method is "
                         + employeeID.ToString());
  }
}
<DataObjectAttribute()> _
Public Class NorthwindData

  <DataObjectMethodAttribute(DataObjectMethodType.Select, True)> _
  Public Shared Function GetAllEmployees() As IEnumerable
    Dim ads As New AccessDataSource()
    ads.DataSourceMode = SqlDataSourceMode.DataReader
    ads.DataFile = "~/App_Data/Northwind.mdb"
    ads.SelectCommand = "SELECT EmployeeID,FirstName,LastName FROM Employees"
    Return ads.Select(DataSourceSelectArguments.Empty)
  End Function 'GetAllEmployees

  ' Delete the Employee by ID.
  <DataObjectMethodAttribute(DataObjectMethodType.Delete, True)> _
  Public Sub DeleteEmployeeByID(ByVal employeeID As Integer)
    Throw New Exception("The value passed to the delete method is " + employeeID.ToString())
  End Sub

End Class

備註

IsDataObject屬性設定為使用true建構子時DataObjectAttribute()的狀態。

適用於

DataObjectAttribute(Boolean)

來源:
DataObjectAttribute.cs
來源:
DataObjectAttribute.cs
來源:
DataObjectAttribute.cs
來源:
DataObjectAttribute.cs
來源:
DataObjectAttribute.cs

初始化該類別的新實例 DataObjectAttribute ,並指示物件是否適合綁定到物件 ObjectDataSource

public:
 DataObjectAttribute(bool isDataObject);
public DataObjectAttribute(bool isDataObject);
new System.ComponentModel.DataObjectAttribute : bool -> System.ComponentModel.DataObjectAttribute
Public Sub New (isDataObject As Boolean)

參數

isDataObject
Boolean

true 若物件適合綁定於物件 ObjectDataSource ;否則, false

備註

使用 DataObjectAttribute(Boolean) 建構子指示設計時類別 ObjectDataSourceDesigner ,例如類別,應排除某物件從適合綁定物件 ObjectDataSource 的清單中。

屬性 IsDataObject 設定為參數的 isDataObject 值。

適用於