DataObjectMethodType 枚举
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
标识由方法执行的数据操作的类型,由应用于该方法的 DataObjectMethodAttribute 指定。
public enum class DataObjectMethodType
public enum DataObjectMethodType
type DataObjectMethodType =
Public Enum DataObjectMethodType
- 继承
字段
| 名称 | 值 | 说明 |
|---|---|---|
| Fill | 0 | 指示方法用于填充 DataSet 对象的数据操作。 |
| Select | 1 | 指示方法用于检索数据的数据操作。 |
| Update | 2 | 指示方法用于更新数据的数据操作。 |
| Insert | 3 | 指示方法用于插入数据的数据操作。 |
| Delete | 4 | 指示方法用于删除数据的数据操作。 |
示例
下面的代码示例演示如何将它应用于 DataObjectMethodAttribute 公开的方法并标识它执行的数据操作的类型,以及它是否为类型的默认数据方法。 在此示例中,该 NorthwindEmployee 类型公开两种不同的数据方法:一个用于检索一组命名 GetAllEmployees的数据,另一个用于删除命名 DeleteEmployeeByID的数据。 这 DataObjectMethodAttribute 两种方法都适用。
[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