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