DataObjectAttribute クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
型を、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 属性を適用して、 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 オブジェクトで使用するのに適したオブジェクトを識別します。 ObjectDataSourceDesigner クラスなどのデザイン時クラスでは、DataObjectAttribute属性を使用して、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) |