Sugerir traducción
 
Otros han sugerido:

progress indicator
No hay más sugerencias.
Evaluar y enviar comentarios
Contraer todo/Expandir todo Contraer todo
Ver contenido:  en paraleloVer contenido: en paralelo
.NET Framework Class Library
UniqueConstraint Class

Represents a restriction on a set of columns in which all values must be unique.

System..::.Object
  System.Data..::.Constraint
    System.Data..::.UniqueConstraint

Namespace:  System.Data
Assembly:  System.Data (in System.Data.dll)
Visual Basic
Public Class UniqueConstraint _
    Inherits Constraint
C#
public class UniqueConstraint : Constraint
Visual C++
public ref class UniqueConstraint : public Constraint
F#
type UniqueConstraint =  
    class
        inherit Constraint
    end

The UniqueConstraint type exposes the following members.

  NameDescription
Public methodSupported by the XNA FrameworkUniqueConstraint(DataColumn)Initializes a new instance of the UniqueConstraint class with the specified DataColumn.
Public methodSupported by the XNA FrameworkUniqueConstraint(array<DataColumn>[]()[])Initializes a new instance of the UniqueConstraint class with the given array of DataColumn objects.
Public methodSupported by the XNA FrameworkUniqueConstraint(DataColumn, Boolean)Initializes a new instance of the UniqueConstraint class with the DataColumn to constrain, and a value specifying whether the constraint is a primary key.
Public methodSupported by the XNA FrameworkUniqueConstraint(array<DataColumn>[]()[], Boolean)Initializes a new instance of the UniqueConstraint class with an array of DataColumn objects to constrain, and a value specifying whether the constraint is a primary key.
Public methodSupported by the XNA FrameworkUniqueConstraint(String, DataColumn)Initializes a new instance of the UniqueConstraint class with the specified name and DataColumn.
Public methodSupported by the XNA FrameworkUniqueConstraint(String, array<DataColumn>[]()[])Initializes a new instance of the UniqueConstraint class with the specified name and array of DataColumn objects.
Public methodSupported by the XNA FrameworkUniqueConstraint(String, DataColumn, Boolean)Initializes a new instance of the UniqueConstraint class with the specified name, the DataColumn to constrain, and a value specifying whether the constraint is a primary key.
Public methodSupported by the XNA FrameworkUniqueConstraint(String, array<DataColumn>[]()[], Boolean)Initializes a new instance of the UniqueConstraint class with the specified name, an array of DataColumn objects to constrain, and a value specifying whether the constraint is a primary key.
Public methodSupported by the XNA FrameworkUniqueConstraint(String, array<String>[]()[], Boolean)Initializes a new instance of the UniqueConstraint class with the specified name, an array of DataColumn objects to constrain, and a value specifying whether the constraint is a primary key.
Top
  NameDescription
Protected propertySupported by the XNA Framework_DataSetInfrastructure. Gets the DataSet to which this constraint belongs. (Inherited from Constraint.)
Public propertySupported by the XNA FrameworkColumnsGets the array of columns that this constraint affects.
Public propertySupported by the XNA FrameworkConstraintNameThe name of a constraint in the ConstraintCollection. (Inherited from Constraint.)
Public propertySupported by the XNA FrameworkExtendedPropertiesGets the collection of user-defined constraint properties. (Inherited from Constraint.)
Public propertySupported by the XNA FrameworkIsPrimaryKeyGets a value indicating whether or not the constraint is on a primary key.
Public propertySupported by the XNA FrameworkTableGets the table to which this constraint belongs. (Overrides Constraint..::.Table.)
Top
  NameDescription
Protected methodSupported by the XNA FrameworkCheckStateForPropertyInfrastructure. Gets the DataSet to which this constraint belongs. (Inherited from Constraint.)
Public methodSupported by the XNA FrameworkEqualsCompares this constraint to a second to determine if both are identical. (Overrides Object..::.Equals(Object).)
Protected methodSupported by the XNA FrameworkFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by the XNA FrameworkGetHashCodeGets the hash code of this instance of the UniqueConstraint object. (Overrides Object..::.GetHashCode()()().)
Public methodSupported by the XNA FrameworkGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkSetDataSetSets the constraint's DataSet. (Inherited from Constraint.)
Public methodSupported by the XNA FrameworkToStringGets the ConstraintName, if there is one, as a string. (Inherited from Constraint.)
Top

The UniqueConstraint is enforced on a single column (or columns) to ensure that a primary key value is unique.

Constraints are not enforced unless the EnforceConstraints property is set to true.

When the a DataSet is merged with a second DataSet, constraints are not enforced until all merges are completed.

The following example adds a UniqueConstraint to a DataSet and sets the EnforceConstraints property to true.

Visual Basic
Public Sub CreateDataTable()
    Dim dataTable As DataTable = New DataTable
    dataTable.Columns.Add("CustomerID", Type.GetType("System.String"))
    dataTable.Columns.Add("CompanyName", Type.GetType("System.String"))

    Dim uniqueConstraint As UniqueConstraint = _
      New UniqueConstraint("CustConstraint", _
      New DataColumn() {dataTable.Columns("CustomerID"), _
      dataTable.Columns("CompanyName")})

    dataTable.Constraints.Add(uniqueConstraint)
End Sub

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

This type is suitable for multithreaded read operations. You must synchronize any write operations.

Biblioteca de clases de .NET Framework
UniqueConstraint (Clase)

Representa una restricción en un conjunto de columnas en el que todos los valores deben ser únicos.

System..::.Object
  System.Data..::.Constraint
    System.Data..::.UniqueConstraint

Espacio de nombres:  System.Data
Ensamblado:  System.Data (en System.Data.dll)
Visual Basic
Public Class UniqueConstraint _
    Inherits Constraint
C#
public class UniqueConstraint : Constraint
Visual C++
public ref class UniqueConstraint : public Constraint
F#
type UniqueConstraint =  
    class
        inherit Constraint
    end

El tipo UniqueConstraint expone los siguientes miembros.

  NombreDescripción
Método públicoCompatible con XNA FrameworkUniqueConstraint(DataColumn)Inicializa una nueva instancia de la clase UniqueConstraint con la enumeración DataColumn especificada.
Método públicoCompatible con XNA FrameworkUniqueConstraint(array<DataColumn>[]()[])Inicializa una nueva instancia de la clase UniqueConstraint con la matriz de objetos dada DataColumn.
Método públicoCompatible con XNA FrameworkUniqueConstraint(DataColumn, Boolean)Inicializa una nueva instancia de la clase UniqueConstraint con el DataColumn que se va a restringir y un valor que especifica si la restricción es una clave principal.
Método públicoCompatible con XNA FrameworkUniqueConstraint(array<DataColumn>[]()[], Boolean)Inicializa una nueva instancia de la clase UniqueConstraint con una matriz de objetos DataColumn que se va a restringir y un valor que especifica si la restricción es una clave principal.
Método públicoCompatible con XNA FrameworkUniqueConstraint(String, DataColumn)Inicializa una nueva instancia de la clase UniqueConstraint con el nombre y DataColumn especificados.
Método públicoCompatible con XNA FrameworkUniqueConstraint(String, array<DataColumn>[]()[])Inicializa una nueva instancia de la clase UniqueConstraint con el nombre y la matriz de objetos DataColumn especificados.
Método públicoCompatible con XNA FrameworkUniqueConstraint(String, DataColumn, Boolean)Inicializa una nueva instancia de la clase UniqueConstraint con el nombre especificado, el DataColumn que se va a restringir y un valor que especifica si la restricción es una clave principal.
Método públicoCompatible con XNA FrameworkUniqueConstraint(String, array<DataColumn>[]()[], Boolean)Inicializa una nueva instancia de la clase UniqueConstraint con el nombre especificado, una matriz de objetos DataColumn que se va a restringir y un valor que especifica si la restricción es una clave principal.
Método públicoCompatible con XNA FrameworkUniqueConstraint(String, array<String>[]()[], Boolean)Inicializa una nueva instancia de la clase UniqueConstraint con el nombre especificado, una matriz de objetos DataColumn que se va a restringir y un valor que especifica si la restricción es una clave principal.
Arriba
  NombreDescripción
Propiedad protegidaCompatible con XNA Framework_DataSetInfraestructura. Obtiene el objeto DataSet al que pertenece esta restricción. (Se hereda de Constraint).
Propiedad públicaCompatible con XNA FrameworkColumnsObtiene la matriz de columnas a la que afecta esta restricción.
Propiedad públicaCompatible con XNA FrameworkConstraintNameNombre de una restricción en el ConstraintCollection. (Se hereda de Constraint).
Propiedad públicaCompatible con XNA FrameworkExtendedPropertiesObtiene la colección de propiedades de restricción definidas por el usuario. (Se hereda de Constraint).
Propiedad públicaCompatible con XNA FrameworkIsPrimaryKeyObtiene un valor que indica si la restricción está o no en una clave principal.
Propiedad públicaCompatible con XNA FrameworkTableObtiene la tabla a la que pertenece esta restricción. (Invalida a Constraint..::.Table).
Arriba
  NombreDescripción
Método protegidoCompatible con XNA FrameworkCheckStateForPropertyInfraestructura. Obtiene el objeto DataSet al que pertenece esta restricción. (Se hereda de Constraint).
Método públicoCompatible con XNA FrameworkEqualsCompara esta restricción con una segunda para determinar si ambas son idénticas. (Invalida a Object..::.Equals(Object)).
Método protegidoCompatible con XNA FrameworkFinalizePermite que un objeto intente liberar recursos y realizar otras operaciones de limpieza antes de ser reclamado por la recolección de elementos no utilizados. (Se hereda de Object).
Método públicoCompatible con XNA FrameworkGetHashCodeObtiene el código hash de esta instancia del objeto UniqueConstraint. (Invalida a Object..::.GetHashCode()()()).
Método públicoCompatible con XNA FrameworkGetTypeObtiene el objeto Type de la instancia actual. (Se hereda de Object).
Método protegidoCompatible con XNA FrameworkMemberwiseCloneCrea una copia superficial del objeto Object actual. (Se hereda de Object).
Método protegidoCompatible con XNA FrameworkSetDataSetEstablece el objeto DataSet de la restricción. (Se hereda de Constraint).
Método públicoCompatible con XNA FrameworkToStringObtiene el ConstraintName, si existe, como una cadena. (Se hereda de Constraint).
Arriba

UniqueConstraint se fuerza en una sola columna (o columnas) para garantizar que un valor de clave principal es único.

Las restricciones no se fuerzan a menos que la propiedad EnforceConstraints esté establecida en true.

Cuando un DataSet se combina con un segundo DataSet, las restricciones no se fuerzan hasta que se completan todos las combinaciones.

En el ejemplo siguiente se agrega un UniqueConstraint a un DataSet y se establece la propiedad EnforceConstraints en true.

Visual Basic
Public Sub CreateDataTable()
    Dim dataTable As DataTable = New DataTable
    dataTable.Columns.Add("CustomerID", Type.GetType("System.String"))
    dataTable.Columns.Add("CompanyName", Type.GetType("System.String"))

    Dim uniqueConstraint As UniqueConstraint = _
      New UniqueConstraint("CustConstraint", _
      New DataColumn() {dataTable.Columns("CustomerID"), _
      dataTable.Columns("CompanyName")})

    dataTable.Constraints.Add(uniqueConstraint)
End Sub

.NET Framework

Compatible con: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Compatible con: 4, 3.5 SP1

Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2

.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Este tipo es adecuado para operaciones de lectura multiproceso. Debe sincronizar cualquier operación de escritura.

Contenido de la comunidad   ¿Qué es Community Content?
Agregar contenido nuevo RSS  Anotaciones
Processing
© 2012 Microsoft. Reservados todos los derechos. Términos de uso | Marcas Registradas | Privacidad
Page view tracker