DataObjectMethodType Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
- Inheritance
Fields
Name | Value | Description |
---|---|---|
Fill | 0 | Indicates that a method is used for a data operation that fills a DataSet object. |
Select | 1 | Indicates that a method is used for a data operation that retrieves data. |
Update | 2 | Indicates that a method is used for a data operation that updates data. |
Insert | 3 | Indicates that a method is used for a data operation that inserts data. |
Delete | 4 | Indicates that a method is used for a data operation that deletes data. |
Examples
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. 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
. 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