Share via


DataObjectAttribute Oluşturucular

Tanım

DataObjectAttribute sınıfının yeni bir örneğini başlatır.

Aşırı Yüklemeler

DataObjectAttribute()

DataObjectAttribute sınıfının yeni bir örneğini başlatır.

DataObjectAttribute(Boolean)

sınıfının yeni bir örneğini başlatır ve bir nesnenin DataObjectAttribute bir nesneye ObjectDataSource bağlama için uygun olup olmadığını gösterir.

DataObjectAttribute()

Kaynak:
DataObjectAttribute.cs
Kaynak:
DataObjectAttribute.cs
Kaynak:
DataObjectAttribute.cs

DataObjectAttribute sınıfının yeni bir örneğini başlatır.

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

Örnekler

Aşağıdaki kod örneği oluşturucunun DataObjectAttribute() kullanılmasını gösterir.

[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

Açıklamalar

IsDataObject oluşturucuyu kullandığınızda DataObjectAttribute() özelliği olarak true ayarlanır.

Şunlara uygulanır

DataObjectAttribute(Boolean)

Kaynak:
DataObjectAttribute.cs
Kaynak:
DataObjectAttribute.cs
Kaynak:
DataObjectAttribute.cs

sınıfının yeni bir örneğini başlatır ve bir nesnenin DataObjectAttribute bir nesneye ObjectDataSource bağlama için uygun olup olmadığını gösterir.

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

Parametreler

isDataObject
Boolean

true nesne bir nesneye bağlama için ObjectDataSource uygunsa; değilse, false.

Açıklamalar

Bir nesnenin DataObjectAttribute(Boolean) bir nesneye bağlanması için uygun nesneler listesinden dışlanması gerektiğini sınıfı gibi ObjectDataSourceDesigner bir tasarım zamanı sınıfına ObjectDataSource göstermek için oluşturucuyu kullanın.

IsDataObject özelliği parametresinin isDataObject değerine ayarlanır.

Şunlara uygulanır