DataObjectAttribute Costruttori

Definizione

Inizializza una nuova istanza della classe DataObjectAttribute.

Overload

DataObjectAttribute()

Inizializza una nuova istanza della classe DataObjectAttribute.

DataObjectAttribute(Boolean)

Inizializza una nuova istanza della classe DataObjectAttribute e indica se un oggetto è adatto per l'associazione a un oggetto ObjectDataSource.

DataObjectAttribute()

Source:
DataObjectAttribute.cs
Source:
DataObjectAttribute.cs
Source:
DataObjectAttribute.cs

Inizializza una nuova istanza della classe DataObjectAttribute.

public:
 DataObjectAttribute();
public DataObjectAttribute ();
Public Sub New ()

Esempio

Nell'esempio di codice seguente viene illustrato l'uso del DataObjectAttribute() costruttore.

[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

Commenti

La IsDataObject proprietà è impostata su true quando si usa il DataObjectAttribute() costruttore.

Si applica a

DataObjectAttribute(Boolean)

Source:
DataObjectAttribute.cs
Source:
DataObjectAttribute.cs
Source:
DataObjectAttribute.cs

Inizializza una nuova istanza della classe DataObjectAttribute e indica se un oggetto è adatto per l'associazione a un oggetto ObjectDataSource.

public:
 DataObjectAttribute(bool isDataObject);
public DataObjectAttribute (bool isDataObject);
new System.ComponentModel.DataObjectAttribute : bool -> System.ComponentModel.DataObjectAttribute
Public Sub New (isDataObject As Boolean)

Parametri

isDataObject
Boolean

true se l'oggetto è adatto per l'associazione a un oggetto ObjectDataSource; in caso contrario, false.

Commenti

Utilizzare il DataObjectAttribute(Boolean) costruttore per indicare a una classe in fase di progettazione, ad esempio la classe che un oggetto deve essere escluso dall'elenco di oggetti appropriati per l'associazione ObjectDataSourceDesigner a un ObjectDataSource oggetto.

La IsDataObject proprietà è impostata sul valore del isDataObject parametro.

Si applica a