DataObjectAttribute クラス

定義

ある型を、ObjectDataSource オブジェクトへのバインドに適したオブジェクトとして識別します。 このクラスは継承できません。

public ref class DataObjectAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class DataObjectAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type DataObjectAttribute = class
    inherit Attribute
Public NotInheritable Class DataObjectAttribute
Inherits Attribute
継承
DataObjectAttribute
属性

次のコード例では、 属性を DataObjectAttribute 適用して、オブジェクトがオブジェクトへのバインドに適しているかどうかを示す方法を ObjectDataSource 示します。 この例では、 NorthwindData オブジェクトは オブジェクトと共に ObjectDataSource 使用することを目的としています。

[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

注釈

属性を DataObjectAttribute 使用して、オブジェクトが使用するのに適した ObjectDataSource オブジェクトを識別します。 クラスなどのデザイン時クラスでは、 属性をObjectDataSourceDesignerDataObjectAttribute使用して、オブジェクトにバインドするのに適したオブジェクトをObjectDataSource提示します。

属性の使用の詳細については、「 属性」を参照してください。

コンストラクター

DataObjectAttribute()

DataObjectAttribute クラスの新しいインスタンスを初期化します。

DataObjectAttribute(Boolean)

DataObjectAttribute クラスの新しいインスタンスを初期化し、オブジェクトが ObjectDataSource オブジェクトへのバインドに適しているかどうかを示します。

フィールド

DataObject

クラスがデザイン時の ObjectDataSource オブジェクトへのバインドに適していることを示します。 このフィールドは読み取り専用です。

Default

クラスがデザイン時の DataObjectAttribute オブジェクトへのバインドに適していることを示す、ObjectDataSource クラスの既定値を表します。 このフィールドは読み取り専用です。

NonDataObject

クラスがデザイン時の ObjectDataSource オブジェクトへのバインドに適していないことを示します。 このフィールドは読み取り専用です。

プロパティ

IsDataObject

オブジェクトがデザイン時の ObjectDataSource オブジェクトへのバインドに適していると見なされるかどうかを示す値を取得します。

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)

メソッド

Equals(Object)

DataObjectAttribute のこのインスタンスが別のオブジェクトのパターンと一致するかどうかを確認します。

GetHashCode()

このインスタンスのハッシュ コードを返します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

属性の現在の値が既定値かどうかを示す値を取得します。

Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象