Search documentationEsc

UniqueKeyAttribute

The unique key attribute exposes the ability to declaratively

Namespace: Microsoft.Azure.CosmosRepository.Attributes
Kind: class

The unique key attribute exposes the ability to declaratively specify an IItem’s properties that can contribute to a unique key constraint. For more information, see https://learn.microsoft.com/azure/cosmos-db/unique-keys.

[AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = true)]
public sealed class UniqueKeyAttribute : Attribute

Remarks

Constructor accepting the keyName for a given IItem’s property.

Example

Members

Constructor

UniqueKeyAttribute.UniqueKeyAttribute(string?, string?)

The unique key attribute exposes the ability to declaratively specify an IItem’s properties that can contribute to a unique key constraint. For more information, see https://learn.microsoft.com/azure/cosmos-db/unique-keys.

public UniqueKeyAttribute(string? keyName = null, string? propertyPath = null)

Parameters

NameTypeDescription
keyNameString
propertyPathStringThe property path to match for the constraint

Constructor accepting the keyName for a given IItem’s property.

Propertys

UniqueKeyAttribute.KeyName

Gets the key name that represents the unique key.

public string KeyName { get; }

ReturnsString

This is the unique name to match a set of paths on

UniqueKeyAttribute.PropertyPath

The property path to use for the key

public string? PropertyPath { get; set; }

ReturnsString