Servicestack.Ormlite中的复合索引

时间:2014-03-18 15:32:43

标签: servicestack ormlite-servicestack

有没有办法在Servicestack的Ormlite实现中创建复合非唯一索引?

例如,一个索引将按顺序覆盖Field1和Field2。

public class Poco
{
    [AutoIncrement]
    public int Id { get; set; }
    ...

    public string Field1 { get; set; }
    public string Field2 { get; set; }
}

1 个答案:

答案 0 :(得分:4)

您可以使用CompositeIndexAttribute,例如:

[CompositeIndex("Field1", "Field2")]
public class Poco
{
    [AutoIncrement]
    public int Id { get; set; }

    public string Field1 { get; set; }
    public string Field2 { get; set; }
}