DataObjectAttribute Constructors

Definition

Initializes a new instance of the DataObjectAttribute class.

Overloads

DataObjectAttribute()

Initializes a new instance of the DataObjectAttribute class.

DataObjectAttribute(Boolean)

Initializes a new instance of the DataObjectAttribute class and indicates whether an object is suitable for binding to an ObjectDataSource object.

DataObjectAttribute()

Source:
DataObjectAttribute.cs
Source:
DataObjectAttribute.cs
Source:
DataObjectAttribute.cs

Initializes a new instance of the DataObjectAttribute class.

C#
public DataObjectAttribute();

Examples

The following code example demonstrates using the DataObjectAttribute() constructor.

C#
[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());
  }
}

Remarks

The IsDataObject property is set to true when you use the DataObjectAttribute() constructor.

Applies to

.NET 10 a ďalšie verzie
Produkt Verzie
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

DataObjectAttribute(Boolean)

Source:
DataObjectAttribute.cs
Source:
DataObjectAttribute.cs
Source:
DataObjectAttribute.cs

Initializes a new instance of the DataObjectAttribute class and indicates whether an object is suitable for binding to an ObjectDataSource object.

C#
public DataObjectAttribute(bool isDataObject);

Parameters

isDataObject
Boolean

true if the object is suitable for binding to an ObjectDataSource object; otherwise, false.

Remarks

Use the DataObjectAttribute(Boolean) constructor to indicate to a design-time class such as the ObjectDataSourceDesigner class that an object should be excluded from the list of suitable objects for binding to an ObjectDataSource object.

The IsDataObject property is set to the value of the isDataObject parameter.

Applies to

.NET 10 a ďalšie verzie
Produkt Verzie
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1