DataObjectAttribute クラス
アセンブリ: System (system.dll 内)

<AttributeUsageAttribute(AttributeTargets.Class)> _ Public NotInheritable Class DataObjectAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class)] public sealed class DataObjectAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class)] public ref class DataObjectAttribute sealed : public Attribute

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

DataObjectAttribute 属性を適用して、オブジェクトが ObjectDataSource オブジェクトへのバインドに適しているかどうかを示す方法を次のコード例に示します。この例で、NorthwindData オブジェクトは、ObjectDataSource オブジェクトと共に使用することを目的としています。
<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 'DeleteEmployeeByID End Class 'NorthwindData
[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()); } }

System.Attribute
System.ComponentModel.DataObjectAttribute


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DataObjectAttribute クラスのページへのリンク