Table of Contents

Class DocumentIdAttribute

Namespace
DataStax.AstraDB.DataApi.SerDes
Assembly
DataStax.AstraDB.DataApi.dll

Marks a property on a document as the unique ID

[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false)]
public class DocumentIdAttribute : Attribute, _Attribute
Inheritance
DocumentIdAttribute
Implements
Inherited Members

Constructors

DocumentIdAttribute()

Initializes a new instance of the DocumentIdAttribute class.

public DocumentIdAttribute()

Remarks

  1. If you want the database to auto-generate Ids for the documents, please use the DocumentIdAttribute(DefaultIdType) overload. When not specified, DefaultIdType.Uuid (UUID v4) will be used.
  2. Please note that the C# type used for the property/field that this attribute is assigned to must match the type associated with the specified default ID (or you need to always pass in a value for the Id field).

DocumentIdAttribute(DefaultIdType)

Initializes a new instance of the DocumentIdAttribute class.

public DocumentIdAttribute(DefaultIdType defaultIdType)

Parameters

defaultIdType DefaultIdType

The type of Id to auto-generate

Remarks

The C# type used for the property/field that this attribute is assigned to must match the type associated with the specified default ID (or use the DocumentIdAttribute() constructor to not set a default type and always pass in a value for the Id field.

Properties

DefaultIdType

If the database is going to auto-generate ids for inserted document, which type of ID should it generate?

public DefaultIdType? DefaultIdType { get; }

Property Value

DefaultIdType?