DataObjectFieldAttribute Constructors

Definition

Initializes a new instance of the DataObjectFieldAttribute class.

Overloads

DataObjectFieldAttribute(Boolean)

Initializes a new instance of the DataObjectFieldAttribute class and indicates whether the field is the primary key for the data row.

DataObjectFieldAttribute(Boolean, Boolean)

Initializes a new instance of the DataObjectFieldAttribute class and indicates whether the field is the primary key for the data row, and whether the field is a database identity field.

DataObjectFieldAttribute(Boolean, Boolean, Boolean)

Initializes a new instance of the DataObjectFieldAttribute class and indicates whether the field is the primary key for the data row, whether the field is a database identity field, and whether the field can be null.

DataObjectFieldAttribute(Boolean, Boolean, Boolean, Int32)

Initializes a new instance of the DataObjectFieldAttribute class and indicates whether the field is the primary key for the data row, whether it is a database identity field, and whether it can be null and sets the length of the field.

DataObjectFieldAttribute(Boolean)

Source:
DataObjectFieldAttribute.cs
Source:
DataObjectFieldAttribute.cs
Source:
DataObjectFieldAttribute.cs

Initializes a new instance of the DataObjectFieldAttribute class and indicates whether the field is the primary key for the data row.

public:
 DataObjectFieldAttribute(bool primaryKey);
public DataObjectFieldAttribute (bool primaryKey);
new System.ComponentModel.DataObjectFieldAttribute : bool -> System.ComponentModel.DataObjectFieldAttribute
Public Sub New (primaryKey As Boolean)

Parameters

primaryKey
Boolean

true to indicate that the field is in the primary key of the data row; otherwise, false.

Applies to

DataObjectFieldAttribute(Boolean, Boolean)

Source:
DataObjectFieldAttribute.cs
Source:
DataObjectFieldAttribute.cs
Source:
DataObjectFieldAttribute.cs

Initializes a new instance of the DataObjectFieldAttribute class and indicates whether the field is the primary key for the data row, and whether the field is a database identity field.

public:
 DataObjectFieldAttribute(bool primaryKey, bool isIdentity);
public DataObjectFieldAttribute (bool primaryKey, bool isIdentity);
new System.ComponentModel.DataObjectFieldAttribute : bool * bool -> System.ComponentModel.DataObjectFieldAttribute
Public Sub New (primaryKey As Boolean, isIdentity As Boolean)

Parameters

primaryKey
Boolean

true to indicate that the field is in the primary key of the data row; otherwise, false.

isIdentity
Boolean

true to indicate that the field is an identity field that uniquely identifies the data row; otherwise, false.

Applies to

DataObjectFieldAttribute(Boolean, Boolean, Boolean)

Source:
DataObjectFieldAttribute.cs
Source:
DataObjectFieldAttribute.cs
Source:
DataObjectFieldAttribute.cs

Initializes a new instance of the DataObjectFieldAttribute class and indicates whether the field is the primary key for the data row, whether the field is a database identity field, and whether the field can be null.

public:
 DataObjectFieldAttribute(bool primaryKey, bool isIdentity, bool isNullable);
public DataObjectFieldAttribute (bool primaryKey, bool isIdentity, bool isNullable);
new System.ComponentModel.DataObjectFieldAttribute : bool * bool * bool -> System.ComponentModel.DataObjectFieldAttribute
Public Sub New (primaryKey As Boolean, isIdentity As Boolean, isNullable As Boolean)

Parameters

primaryKey
Boolean

true to indicate that the field is in the primary key of the data row; otherwise, false.

isIdentity
Boolean

true to indicate that the field is an identity field that uniquely identifies the data row; otherwise, false.

isNullable
Boolean

true to indicate that the field can be null in the data store; otherwise, false.

Examples

The following code example demonstrates how you can apply the DataObjectFieldAttribute to a publicly exposed property to identify metadata associated with the property. In this example the NorthwindEmployee type exposes three data properties: EmployeeID, FirstName, and LastName. The DataObjectFieldAttribute attribute is applied to all three properties; however, only the EmployeeID property attribute indicates it is the primary key for the data row.

public class NorthwindEmployee
{
  public NorthwindEmployee() { }

  private int _employeeID;
  [DataObjectFieldAttribute(true, true, false)]
  public int EmployeeID
  {
    get { return _employeeID; }
    set { _employeeID = value; }
  }

  private string _firstName = String.Empty;
  [DataObjectFieldAttribute(false, false, true)]
  public string FirstName
  {
    get { return _firstName; }
    set { _firstName = value; }
  }

  private string _lastName = String.Empty;
  [DataObjectFieldAttribute(false, false, true)]
  public string LastName
  {
    get { return _lastName; }
    set { _lastName = value; }
  }
}
Public Class NorthwindEmployee

  Public Sub New()
  End Sub

  Private _employeeID As Integer
  <DataObjectFieldAttribute(True, True, False)> _
  Public Property EmployeeID() As Integer
    Get
      Return _employeeID
    End Get
    Set(ByVal value As Integer)
      _employeeID = value
    End Set
  End Property

  Private _firstName As String = String.Empty
  <DataObjectFieldAttribute(False, False, False)> _
  Public Property FirstName() As String
    Get
      Return _firstName
    End Get
    Set(ByVal value As String)
      _firstName = value
    End Set
  End Property

  Private _lastName As String = String.Empty
  <DataObjectFieldAttribute(False, False, False)> _
  Public Property LastName() As String
    Get
      Return _lastName
    End Get
    Set(ByVal value As String)
      _lastName = value
    End Set
  End Property

End Class

Applies to

DataObjectFieldAttribute(Boolean, Boolean, Boolean, Int32)

Source:
DataObjectFieldAttribute.cs
Source:
DataObjectFieldAttribute.cs
Source:
DataObjectFieldAttribute.cs

Initializes a new instance of the DataObjectFieldAttribute class and indicates whether the field is the primary key for the data row, whether it is a database identity field, and whether it can be null and sets the length of the field.

public:
 DataObjectFieldAttribute(bool primaryKey, bool isIdentity, bool isNullable, int length);
public DataObjectFieldAttribute (bool primaryKey, bool isIdentity, bool isNullable, int length);
new System.ComponentModel.DataObjectFieldAttribute : bool * bool * bool * int -> System.ComponentModel.DataObjectFieldAttribute
Public Sub New (primaryKey As Boolean, isIdentity As Boolean, isNullable As Boolean, length As Integer)

Parameters

primaryKey
Boolean

true to indicate that the field is in the primary key of the data row; otherwise, false.

isIdentity
Boolean

true to indicate that the field is an identity field that uniquely identifies the data row; otherwise, false.

isNullable
Boolean

true to indicate that the field can be null in the data store; otherwise, false.

length
Int32

The length of the field in bytes.

Applies to