Export (0) Print
Expand All

DataObjectMethodAttribute Class

Identifies a data operation method exposed by a type, what type of operation the method performs, and whether the method is the default data method. This class cannot be inherited.

System.Object
  System.Attribute
    System.ComponentModel.DataObjectMethodAttribute

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)

'Declaration
<AttributeUsageAttribute(AttributeTargets.Method)> _
Public NotInheritable Class DataObjectMethodAttribute _
	Inherits Attribute

The DataObjectMethodAttribute type exposes the following members.

  NameDescription
Public methodSupported by the XNA FrameworkDataObjectMethodAttribute(DataObjectMethodType)Initializes a new instance of the DataObjectMethodAttribute class and identifies the type of data operation the method performs.
Public methodSupported by the XNA FrameworkDataObjectMethodAttribute(DataObjectMethodType, Boolean)Initializes a new instance of the DataObjectMethodAttribute class, identifies the type of data operation the method performs, and identifies whether the method is the default data method that the data object exposes.
Top

  NameDescription
Public propertySupported by the XNA FrameworkIsDefaultGets a value indicating whether the method that the DataObjectMethodAttribute is applied to is the default data method exposed by the data object for a specific method type.
Public propertySupported by the XNA FrameworkMethodTypeGets a DataObjectMethodType value indicating the type of data operation the method performs.
Public propertyTypeIdWhen implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)
Top

  NameDescription
Public methodSupported by the XNA FrameworkEqualsReturns a value indicating whether this instance is equal to a specified object. (Overrides Attribute.Equals(Object).)
Protected methodSupported by the XNA FrameworkFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by the XNA FrameworkGetHashCodeReturns the hash code for this instance. (Overrides Attribute.GetHashCode.)
Public methodSupported by the XNA FrameworkGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIsDefaultAttributeWhen overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
Public methodSupported by the XNA FrameworkMatchGets a value indicating whether this instance shares a common pattern with a specified attribute. (Overrides Attribute.Match(Object).)
Protected methodSupported by the XNA FrameworkMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by the XNA FrameworkToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate method_Attribute.GetIDsOfNamesMaps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.GetTypeInfoRetrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.GetTypeInfoCountRetrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.InvokeProvides access to properties and methods exposed by an object. (Inherited from Attribute.)
Top

You can use the DataObjectMethodAttribute to identify data operation methods on a type marked with the DataObjectAttribute attribute so that they are more easily identified by callers using reflection. When the DataObjectMethodAttribute attribute is applied to a method, it describes the type of operation the method performs and indicates whether the method is the default data operation method of a type. Components such as the ObjectDataSource control and the ObjectDataSourceDesigner class examine the values of this attribute, if present, to help determine which data method to call at run time.

The following code example demonstrates how you can apply the DataObjectMethodAttribute attribute to a publicly exposed method and identify the type of data operation it performs as well as whether it is the type's default data method. In this example the NorthwindData type exposes two data methods: one to retrieve a set of data named GetAllEmployees, and another to delete data named DeleteEmployeeByID. The DataObjectMethodAttribute attribute is applied to both methods, the GetAllEmployees method is marked as the default method for the Select data operation, and the DeleteEmployeeByID method is marked as the default method for the Delete data operation.


<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


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft