DataObjectMethodAttribute Constructores

Definición

Inicializa una nueva instancia de la clase DataObjectMethodAttribute.Initializes a new instance of the DataObjectMethodAttribute class.

Sobrecargas

DataObjectMethodAttribute(DataObjectMethodType)

Inicializa una nueva instancia de la clase DataObjectMethodAttribute e identifica el tipo de operación de datos que realiza el método.Initializes a new instance of the DataObjectMethodAttribute class and identifies the type of data operation the method performs.

DataObjectMethodAttribute(DataObjectMethodType, Boolean)

Inicializa una nueva instancia de la clase DataObjectMethodAttribute e identifica el tipo de operación de datos que realiza el método y si es el método de datos predeterminado que expone el objeto de datos.Initializes a new instance of the DataObjectMethodAttribute class, identifies the type of data operation the method performs, and identifies whether the method is the default data method that the data object exposes.

DataObjectMethodAttribute(DataObjectMethodType)

Inicializa una nueva instancia de la clase DataObjectMethodAttribute e identifica el tipo de operación de datos que realiza el método.Initializes a new instance of the DataObjectMethodAttribute class and identifies the type of data operation the method performs.

public:
 DataObjectMethodAttribute(System::ComponentModel::DataObjectMethodType methodType);
public DataObjectMethodAttribute (System.ComponentModel.DataObjectMethodType methodType);
new System.ComponentModel.DataObjectMethodAttribute : System.ComponentModel.DataObjectMethodType -> System.ComponentModel.DataObjectMethodAttribute
Public Sub New (methodType As DataObjectMethodType)

Parámetros

methodType
DataObjectMethodType

Uno de los valores de DataObjectMethodType que describe la operación de datos que realiza el método.One of the DataObjectMethodType values that describes the data operation the method performs.

Ejemplos

En el ejemplo de código siguiente se muestra cómo se puede aplicar el DataObjectMethodAttribute atributo a un método expuesto públicamente e identificar el tipo de operación de datos que realiza, así como si es el método de datos predeterminado del tipo.The following code example demonstrates how you can apply the DataObjectMethodAttribute attribute 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. En este ejemplo NorthwindData , el tipo expone dos métodos de datos: uno para recuperar un conjunto de datos denominado GetAllEmployees y otro para eliminar los datos denominados DeleteEmployeeByID .In this example the NorthwindData type exposes two data methods: one to retrieve a set of data named GetAllEmployees, and another to delete data named DeleteEmployeeByID. El DataObjectMethodAttribute atributo se aplica a ambos métodos, el GetAllEmployees método se marca como el método predeterminado para la operación de selección de datos y el DeleteEmployeeByID método se marca como el método predeterminado para la operación de eliminación de datos.The DataObjectMethodAttribute attribute is applied to both methods, the GetAllEmployees method is marked as the default method for the Select data operation, and the DeleteEmployeeByID method is marked as the default method for the Delete data operation.

[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

Comentarios

La IsDefault propiedad se establece en false cuando se crea un DataObjectMethodAttribute objeto con este DataObjectMethodAttribute(DataObjectMethodType) constructor.The IsDefault property is set to false when you create a DataObjectMethodAttribute object using this DataObjectMethodAttribute(DataObjectMethodType) constructor.

Se aplica a

DataObjectMethodAttribute(DataObjectMethodType, Boolean)

Inicializa una nueva instancia de la clase DataObjectMethodAttribute e identifica el tipo de operación de datos que realiza el método y si es el método de datos predeterminado que expone el objeto de datos.Initializes a new instance of the DataObjectMethodAttribute class, identifies the type of data operation the method performs, and identifies whether the method is the default data method that the data object exposes.

public:
 DataObjectMethodAttribute(System::ComponentModel::DataObjectMethodType methodType, bool isDefault);
public DataObjectMethodAttribute (System.ComponentModel.DataObjectMethodType methodType, bool isDefault);
new System.ComponentModel.DataObjectMethodAttribute : System.ComponentModel.DataObjectMethodType * bool -> System.ComponentModel.DataObjectMethodAttribute
Public Sub New (methodType As DataObjectMethodType, isDefault As Boolean)

Parámetros

methodType
DataObjectMethodType

Uno de los valores de DataObjectMethodType que describe la operación de datos que realiza el método.One of the DataObjectMethodType values that describes the data operation the method performs.

isDefault
Boolean

true para indicar que el método al que se aplica el atributo es el método predeterminado del objeto de datos para el parámetro methodType especificado; de lo contrario, false.true to indicate the method that the attribute is applied to is the default method of the data object for the specified methodType; otherwise, false.

Ejemplos

En el ejemplo de código siguiente se muestra cómo se puede aplicar el DataObjectMethodAttribute atributo a un método expuesto públicamente e identificar el tipo de operación de datos que realiza, así como si es el método de datos predeterminado del tipo.The following code example demonstrates how you can apply the DataObjectMethodAttribute attribute 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. En este ejemplo NorthwindData , el tipo expone dos métodos de datos: uno para recuperar un conjunto de datos denominado GetAllEmployees y otro para eliminar los datos denominados DeleteEmployeeByID .In this example the NorthwindData type exposes two data methods: one to retrieve a set of data named GetAllEmployees, and another to delete data named DeleteEmployeeByID. El DataObjectMethodAttribute atributo se aplica a ambos métodos, el GetAllEmployees método se marca como el método predeterminado para la operación de selección de datos y el DeleteEmployeeByID método se marca como el método predeterminado para la operación de eliminación de datos.The DataObjectMethodAttribute attribute is applied to both methods, the GetAllEmployees method is marked as the default method for the Select data operation, and the DeleteEmployeeByID method is marked as the default method for the Delete data operation.

[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

Se aplica a