DataObjectAttribute Konstruktorok

Definíció

Inicializálja a DataObjectAttribute osztály új példányát.

Túlterhelések

Name Description
DataObjectAttribute()

Inicializálja a DataObjectAttribute osztály új példányát.

DataObjectAttribute(Boolean)

Inicializálja az DataObjectAttribute osztály új példányát, és jelzi, hogy egy objektum alkalmas-e az ObjectDataSource objektumhoz való kötésre.

DataObjectAttribute()

Forrás:
DataObjectAttribute.cs
Forrás:
DataObjectAttribute.cs
Forrás:
DataObjectAttribute.cs
Forrás:
DataObjectAttribute.cs
Forrás:
DataObjectAttribute.cs

Inicializálja a DataObjectAttribute osztály új példányát.

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

Példák

Az alábbi példakód a DataObjectAttribute() konstruktor használatát mutatja be.

[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

Megjegyzések

A IsDataObject tulajdonság a true konstruktor használatakor DataObjectAttribute() van beállítva.

A következőre érvényes:

DataObjectAttribute(Boolean)

Forrás:
DataObjectAttribute.cs
Forrás:
DataObjectAttribute.cs
Forrás:
DataObjectAttribute.cs
Forrás:
DataObjectAttribute.cs
Forrás:
DataObjectAttribute.cs

Inicializálja az DataObjectAttribute osztály új példányát, és jelzi, hogy egy objektum alkalmas-e az ObjectDataSource objektumhoz való kötésre.

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

Paraméterek

isDataObject
Boolean

trueha az objektum alkalmas egy objektumhoz való kötésreObjectDataSource; ellenkező esetben. false

Megjegyzések

DataObjectAttribute(Boolean) A konstruktor használatával jelezheti egy tervezési időosztálynak, például az osztálynak, hogy egy ObjectDataSourceDesigner objektumot ki kell zárni az objektumhoz ObjectDataSource való kötésre alkalmas objektumok listájából.

A IsDataObject tulajdonság a paraméter értékére isDataObject van állítva.

A következőre érvényes: