Bagikan melalui


DataObjectAttribute Konstruktor

Definisi

Menginisialisasi instans baru kelas DataObjectAttribute.

Overload

DataObjectAttribute()

Menginisialisasi instans baru kelas DataObjectAttribute.

DataObjectAttribute(Boolean)

Menginisialisasi instans DataObjectAttribute baru kelas dan menunjukkan apakah objek cocok untuk mengikat objek ObjectDataSource .

DataObjectAttribute()

Sumber:
DataObjectAttribute.cs
Sumber:
DataObjectAttribute.cs
Sumber:
DataObjectAttribute.cs

Menginisialisasi instans baru kelas DataObjectAttribute.

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

Contoh

Contoh kode berikut menunjukkan menggunakan DataObjectAttribute() konstruktor .

[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

Keterangan

Properti IsDataObject diatur ke true saat Anda menggunakan DataObjectAttribute() konstruktor.

Berlaku untuk

DataObjectAttribute(Boolean)

Sumber:
DataObjectAttribute.cs
Sumber:
DataObjectAttribute.cs
Sumber:
DataObjectAttribute.cs

Menginisialisasi instans DataObjectAttribute baru kelas dan menunjukkan apakah objek cocok untuk mengikat objek ObjectDataSource .

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

Parameter

isDataObject
Boolean

true jika objek cocok untuk mengikat ke ObjectDataSource objek; jika tidak, false.

Keterangan

DataObjectAttribute(Boolean) Gunakan konstruktor untuk menunjukkan ke kelas waktu desain seperti ObjectDataSourceDesigner kelas bahwa objek harus dikecualikan dari daftar objek yang ObjectDataSource sesuai untuk pengikatan ke objek.

Properti IsDataObject diatur ke nilai isDataObject parameter .

Berlaku untuk