DataObjectAttribute 构造函数  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 DataObjectAttribute 类的新实例。
重载
| DataObjectAttribute() | 初始化 DataObjectAttribute 类的新实例。 | 
| DataObjectAttribute(Boolean) | 初始化 DataObjectAttribute 类的新实例,并指示某一对象是否适合绑定到 ObjectDataSource 对象。 | 
DataObjectAttribute()
- Source:
- DataObjectAttribute.cs
- Source:
- DataObjectAttribute.cs
- Source:
- DataObjectAttribute.cs
初始化 DataObjectAttribute 类的新实例。
public:
 DataObjectAttribute();public DataObjectAttribute ();Public Sub New ()示例
下面的代码示例演示如何使用 DataObjectAttribute() 构造函数。
[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
注解
              IsDataObject使用 构造函数时, DataObjectAttribute() 属性设置为 true 。
适用于
DataObjectAttribute(Boolean)
- Source:
- DataObjectAttribute.cs
- Source:
- DataObjectAttribute.cs
- Source:
- DataObjectAttribute.cs
初始化 DataObjectAttribute 类的新实例,并指示某一对象是否适合绑定到 ObjectDataSource 对象。
public:
 DataObjectAttribute(bool isDataObject);public DataObjectAttribute (bool isDataObject);new System.ComponentModel.DataObjectAttribute : bool -> System.ComponentModel.DataObjectAttributePublic Sub New (isDataObject As Boolean)参数
- isDataObject
- Boolean
如果该对象适合绑定到 ObjectDataSource 对象,则为 true;否则为 false。
注解
DataObjectAttribute(Boolean)使用 构造函数向设计时类(如 ObjectDataSourceDesigner 类)指示应从要绑定到对象的合适对象列表中排除对象ObjectDataSource。
属性 IsDataObject 设置为 参数的值 isDataObject 。