DataObjectAttribute クラスとは? わかりやすく解説

DataObjectAttribute クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

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

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.Class)> _
Public NotInheritable Class
 DataObjectAttribute
    Inherits Attribute
Dim instance As DataObjectAttribute
[AttributeUsageAttribute(AttributeTargets.Class)] 
public sealed class DataObjectAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class)] 
public ref class DataObjectAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class) */ 
public final class DataObjectAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.Class) 
public final class DataObjectAttribute extends
 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.Object
   System.Attribute
    System.ComponentModel.DataObjectAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DataObjectAttribute クラス」の関連用語

DataObjectAttribute クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataObjectAttribute クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS