DataObjectMethodType 枚举

定义

根据应用于某方法的 DataObjectMethodAttribute 的指定,标识该方法所执行的数据操作类型。

C#
public enum DataObjectMethodType
继承
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());
  }
}

适用于

产品 版本
.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

另请参阅