DataObjectMethodAttribute コンストラクタ (DataObjectMethodType)
アセンブリ: System (system.dll 内)


この DataObjectMethodAttribute(DataObjectMethodType) コンストラクタを使用して DataObjectMethodAttribute オブジェクトを作成すると、IsDefault プロパティが false に設定されます。

パブリックに公開されているメソッドに DataObjectMethodAttribute 属性を適用し、そのメソッドによって実行されるデータ操作の種類、およびそのメソッドがその型の既定のデータ メソッドかどうかを識別する方法を次のコード例に示します。この例では、NorthwindData 型によって 2 つのデータ メソッドが公開されています。1 つは GetAllEmployees という名前のデータのセットを取得するメソッドで、もう 1 つは DeleteEmployeeByID という名前のデータを削除するメソッドです。どちらのメソッドにも DataObjectMethodAttribute 属性が適用され、GetAllEmployees メソッドは Select データ操作の既定のメソッドとしてマークされ、DeleteEmployeeByID メソッドは Delete データ操作の既定のメソッドとしてマークされています。
<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()); } }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataObjectMethodAttribute コンストラクタ (DataObjectMethodType, Boolean)
アセンブリ: System (system.dll 内)

Dim methodType As DataObjectMethodType Dim isDefault As Boolean Dim instance As New DataObjectMethodAttribute(methodType, isDefault)
public function DataObjectMethodAttribute ( methodType : DataObjectMethodType, isDefault : boolean )

パブリックに公開されているメソッドに DataObjectMethodAttribute 属性を適用し、そのメソッドによって実行されるデータ操作の種類、およびそのメソッドがその型の既定のデータ メソッドかどうかを識別する方法を次のコード例に示します。この例では、NorthwindData 型によって 2 つのデータ メソッドが公開されています。1 つは GetAllEmployees という名前のデータのセットを取得するメソッドで、もう 1 つは DeleteEmployeeByID という名前のデータを削除するメソッドです。どちらのメソッドにも DataObjectMethodAttribute 属性が適用され、GetAllEmployees メソッドは Select データ操作の既定のメソッドとしてマークされ、DeleteEmployeeByID メソッドは Delete データ操作の既定のメソッドとしてマークされています。
<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()); } }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataObjectMethodAttribute コンストラクタ

名前 | 説明 |
---|---|
DataObjectMethodAttribute (DataObjectMethodType) | DataObjectMethodAttribute クラスの新しいインスタンスを初期化し、メソッドによって実行されるデータ操作の種類を識別します。 .NET Compact Framework によってサポートされています。 |
DataObjectMethodAttribute (DataObjectMethodType, Boolean) | DataObjectMethodAttribute クラスの新しいインスタンスを初期化して、メソッドによって実行されるデータ操作の種類を識別し、さらにそのメソッドがそのデータ オブジェクトによって公開される既定のデータ メソッドかどうかを識別します。 .NET Compact Framework によってサポートされています。 |

- DataObjectMethodAttribute コンストラクタのページへのリンク