DataColumn.Unique Propiedad

Definición

Obtiene o establece un valor que indica si los valores de cada fila de la columna deben ser únicos.

public:
 property bool Unique { bool get(); void set(bool value); };
public bool Unique { get; set; }
[System.Data.DataSysDescription("DataColumnUniqueDescr")]
public bool Unique { get; set; }
member this.Unique : bool with get, set
[<System.Data.DataSysDescription("DataColumnUniqueDescr")>]
member this.Unique : bool with get, set
Public Property Unique As Boolean

Valor de propiedad

true si el valor debe ser único; en caso contrario, false. De manera predeterminada, es false.

Atributos

Excepciones

La columna es una columna calculada.

Ejemplos

En el ejemplo siguiente se crea , DataColumnse establecen sus propiedades y se agregan a la colección de columnas de una tabla.

private void AddColumn(DataTable table)
{
    // Add a DataColumn to the collection and set its properties.
    // The constructor sets the ColumnName of the column.
    DataColumn column = new DataColumn("Total");
    column.DataType = System.Type.GetType("System.Decimal");
    column.ReadOnly = true;
    column.Expression = "UnitPrice * Quantity";
    column.Unique = false;
}
Private Sub AddColumn(table As DataTable)
    ' Add a DataColumn to the collection and set its properties.
    ' The constructor sets the ColumnName of the column.
    Dim column As New DataColumn("Total")
    column.DataType = System.Type.GetType("System.Decimal")
    column.ReadOnly = True
    column.Expression = "UnitPrice * Quantity"
    column.Unique = False
End Sub

Comentarios

En cuanto esta propiedad cambia de false a true, se creará una restricción única en esta columna para asegurarse de que los valores son únicos.

Se aplica a

Consulte también