Back to Devexpress

IndexedAttribute.Unique Property

xpo-devexpress-dot-xpo-dot-indexedattribute-bfa915a2.md

latest2.1 KB
Original Source

IndexedAttribute.Unique Property

Gets or sets whether the index created by a property or field is a unique one.

Namespace : DevExpress.Xpo

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
public bool Unique { get; set; }
vb
Public Property Unique As Boolean

Property Value

TypeDescription
Boolean

true if the index must be unique (no two persistent objects are permitted to have the same index value); otherwise, false.

|

Remarks

csharp
public class User : XPObject {
    [Indexed(Unique = true)]
    public int UserId {
        get { return fUserId; }
        set { SetPropertyValue(nameof(UserId), ref fUserId, value); }
    }
    int fUserId;

    public string UserName {
        get { return fUserName; }
        set { SetPropertyValue(nameof(UserName), ref fUserName, value); }
    }
    string fUserName;

}
vb
Public Class User
    Inherits XPObject
    <Indexed(Unique:=True)> _
    Public Property UserId() As Integer
        Get
            Return fUserId
        End Get
        Set(ByVal value as Integer)
            SetPropertyValue(NameOf(UserId), fUserId, value)
        End Set
    End Property
    Private fUserId As Integer

    Public Property UserName() As String
        Get
            Return fUserName
        End Get
        Set(ByVal value as String)
            SetPropertyValue(NameOf(UserName), fUserName, value)
        End Set
    End Property
    Private fUserName As String

End Class

See Also

IndexedAttribute Class

IndexedAttribute Members

DevExpress.Xpo Namespace