DataObjectMethodType DataObjectMethodType DataObjectMethodType DataObjectMethodType Enum

定义

根据应用于某方法的 DataObjectMethodAttribute 的指定,标识该方法所执行的数据操作类型。Identifies the type of data operation performed by a method, as specified by the DataObjectMethodAttribute applied to the method.

public enum class DataObjectMethodType
public enum DataObjectMethodType
type DataObjectMethodType = 
Public Enum DataObjectMethodType
继承
DataObjectMethodTypeDataObjectMethodTypeDataObjectMethodTypeDataObjectMethodType

字段

Delete Delete Delete Delete 4

指示某一方法是否用于删除数据的数据操作。Indicates that a method is used for a data operation that deletes data.

Fill Fill Fill Fill 0

指示某一方法是否用于填充 DataSet 对象的数据操作。Indicates that a method is used for a data operation that fills a DataSet object.

Insert Insert Insert Insert 3

指示某一方法是否用于插入数据的数据操作。Indicates that a method is used for a data operation that inserts data.

Select Select Select Select 1

指示某一方法是否用于检索数据的数据操作。Indicates that a method is used for a data operation that retrieves data.

Update Update Update Update 2

指示某一方法是否用于更新数据的数据操作。Indicates that a method is used for a data operation that updates data.

示例

下面的代码示例演示如何将应用DataObjectMethodAttribute于公开显示的方法, 并标识它执行的数据操作的类型以及它是否是类型的默认数据方法。The following code example demonstrates how you can apply the DataObjectMethodAttribute to a publicly exposed method and identify the type of data operation it performs as well as whether it is the type's default data method. 在此示例中NorthwindEmployee , 类型公开了两个不同的数据方法: 一个用于检索一GetAllEmployees组名为的数据, 另DeleteEmployeeByID一个用于删除名为的数据。In this example the NorthwindEmployee type exposes two different data methods: one to retrieve a set of data named GetAllEmployees, and one to delete data named DeleteEmployeeByID. DataObjectMethodAttribute适用于这两种方法。The DataObjectMethodAttribute is applied to both methods.

[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

适用于

另请参阅