Reputation: 24572
I am using this code to create a table:
db2.CreateTable<Phrase>();
Here's the Phrase class:
public class Phrase : IPhrase
{
[PrimaryKey, NotNull]
public string PhraseId { get; set; }
public int PhraseNum { get; set; }
public int CategoryId { get; set; }
public string English { get; set; }
public string Romaji { get; set; }
}
When I hover over the CreateTable it gives a message saying that it creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type.
Does anyone know how I could for example create an index on the PhraseNum?
Upvotes: 0
Views: 145
Reputation: 74144
For a single property-based index add an IndexedAttribute
:
public class Package
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
[Indexed]
public string Name { get; set; }
~~~~
For a multiple field index, use the Name and Order parameters within the IndexedAttribute
:
public class Package
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
[Indexed(Name = "SecondaryIndex", Order = 1)]
public string Name { get; set; }
[Indexed(Name = "SecondaryIndex", Order = 2)]
public string PackageName { get; set; }
~~~
Upvotes: 1