Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataObjectMethodType Enumeration

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Identifies the type of data operation performed by a method, as specified by the DataObjectMethodAttribute applied to the method.

Namespace:   System.ComponentModel
Assembly:  System (in System.dll)

public enum DataObjectMethodType

Member nameDescription
Delete

Indicates that a method is used for a data operation that deletes data.

Fill

Indicates that a method is used for a data operation that fills a DataSet object.

Insert

Indicates that a method is used for a data operation that inserts data.

Select

Indicates that a method is used for a data operation that retrieves data.

Update

Indicates that a method is used for a data operation that updates data.

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());
  }
}

.NET Framework
Available since 2.0
Return to top
Show:
© 2017 Microsoft