DataObjectMethodType 枚举
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
根据应用于某方法的 DataObjectMethodAttribute 的指定,标识该方法所执行的数据操作类型。
public enum class DataObjectMethodType
C#
public enum DataObjectMethodType
type DataObjectMethodType =
Public Enum DataObjectMethodType
- 继承
名称 | 值 | 说明 |
---|---|---|
Delete | 4 | 指示某一方法是否用于删除数据的数据操作。 |
Fill | 0 | 指示某一方法是否用于填充 DataSet 对象的数据操作。 |
Insert | 3 | 指示某一方法是否用于插入数据的数据操作。 |
Select | 1 | 指示某一方法是否用于检索数据的数据操作。 |
Update | 2 | 指示某一方法是否用于更新数据的数据操作。 |
下面的代码示例演示如何将 应用于 DataObjectMethodAttribute 公开的方法,并标识它执行的数据操作的类型,以及它是否为该类型的默认数据方法。 在此示例中, NorthwindEmployee
类型公开了两种不同的数据方法:一种用于检索名为 GetAllEmployees
的一组数据,另一种用于删除名为 的数据 DeleteEmployeeByID
。 将 DataObjectMethodAttribute 应用于这两种方法。
C#
[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
产品 | 版本 |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |