【问题标题】:Ormlite Descending IndexOrmlite 降序索引
【发布时间】:2019-10-02 18:57:32
【问题描述】:

是否可以在 OrmLite 中定义降序索引?我只能看到 [Index] 属性,但我有一个超过 100 万条记录的表,需要一个降序索引。

【问题讨论】:

    标签: servicestack ormlite-servicestack


    【解决方案1】:

    如果是复合索引,您可以在其名称中指定它:

    [CompositeIndex("Field1", "Field2 DESC")]
    public class Table
    {
        ...
        public string Field1 { get; set; }
        public string Field2 { get; set; }
    }
    

    否则你可以使用Pre/Post Custom SQL Hooks,例如:

    [PostCreateTable("CREATE INDEX IX_NAME ON MyTable (Field1 DESC);")]
    public class MyTable
    {
        ...
        public string Field1 { get; set; }
        public string Field2 { get; set; }
    }
    

    创建表后会执行 Post SQL Hook 来创建索引。

    【讨论】:

      猜你喜欢
      • 2010-10-27
      • 2014-10-24
      • 1970-01-01
      • 2019-07-29
      • 1970-01-01
      • 1970-01-01
      • 2012-09-02
      • 2020-01-23
      • 1970-01-01
      相关资源
      最近更新 更多