IndexedColumnsAttribute Class

An attribute that qualifies any class representing a table, creating the index of the table and using the specified column names for the index key.

C#
[AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
public sealed class IndexedColumnsAttribute : Attribute
Inheritance
IndexedColumnsAttribute
Attributes

Examples

[Table("persons")]
[IndexedColumns("firstNameId")]
[IndexedColumns("lastNameId")]
[IndexedColumns("firstNameId", "lastNameId")]
public record class PersonRow(
    [Column("id")][PrimaryKey][AutoIncrement] long Id,
    [Column("firstNameId")] long firstNameId,
    [Column("lastNameId")] long lastNameId)
{
}

[Table("string")]
public record class StringRow(
    [Column("id")][PrimaryKey][AutoIncrement] long Id,
    [Column("value")][Unique] string Value)
{
}{

Remarks

See: SQLite CREATE INDEX.

Constructors

IndexedColumnsAttribute(string[])

Initializes a new instance of the IndexedColumnsAttribute class.

Properties

Names

Gets the column names used for the index key.

TypeId (Inherited from Attribute)

Methods

Equals(object) (Inherited from Attribute)
GetHashCode() (Inherited from Attribute)
IsDefaultAttribute() (Inherited from Attribute)
Match(object) (Inherited from Attribute)
GetType() (Inherited from object)
MemberwiseClone() (Inherited from object)
ToString() (Inherited from object)

Constructors Detail

IndexedColumnsAttribute(string[])

Initializes a new instance of the IndexedColumnsAttribute class.

C#
public IndexedColumnsAttribute(params string[] names)

Parameters

names
string[]

The column names used for the index key.

Properties Detail

Names

Gets the column names used for the index key.

C#
public IReadOnlyList<string> Names { get; }

Property Value