DataObjectMethodType 列挙型

定義

メソッドに適用された DataObjectMethodAttribute で指定された、メソッドによって実行されるデータ操作の種類を示します。

public enum class DataObjectMethodType
public enum DataObjectMethodType
type DataObjectMethodType = 
Public Enum DataObjectMethodType
継承
DataObjectMethodType

フィールド

Delete 4

メソッドが、データを削除するデータ操作に使用されることを示します。

Fill 0

メソッドが、DataSet オブジェクトにデータを格納するデータ操作に使用されることを示します。

Insert 3

メソッドが、データを挿入するデータ操作に使用されることを示します。

Select 1

メソッドが、データを取得するデータ操作に使用されることを示します。

Update 2

メソッドが、データを更新するデータ操作に使用されることを示します。

次のコード例では、 をパブリックに公開されているメソッドに適用 DataObjectMethodAttribute し、実行するデータ操作の種類と、それが型の既定のデータ メソッドであるかどうかを識別する方法を示します。 この例では、 型は NorthwindEmployee 2 つの異なるデータ メソッドを公開しています。1 つは という名前 GetAllEmployeesのデータ セットを取得し、もう 1 つは という名前のデータを削除するメソッドです DeleteEmployeeByIDDataObjectMethodAttributeは両方のメソッドに適用されます。

[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

適用対象

こちらもご覧ください