如何在sqlite.net中设置整理LOCALIZED(Xamarin Android)

时间:2016-02-23 14:30:23

标签: android xamarin

如何将排序规则应用于sqlite.net文本列? (Xamarin Android SQLIte.Net组件)

我试过了:

  public List<CountryInfo> HoleCountryList()
        {
            //var query = conn.Table<CountryInfo>().OrderBy(v=>v.country);
            var query = conn.Query<CountryInfo>("select * from CountryInfo order by country COLLATE LOCALIZED");
            return query.ToList<CountryInfo>();
        }

会导致以下错误:

  

没有这样的归类序列:LOCALIZED“”SQLite-net“at   SQLite.SQLite3.Prepare2(SQLitePCL.sqlite3 db,System.String查询)   [Users000 / fak / Dro中的[0x00012] ...

1 个答案:

答案 0 :(得分:0)

由于Xamarin SQLite.net不提供特定国家/地区的排序规则,我通过对结果列表进行排序来解决我的问题。这工作正常!

 public List<CountryInfo> HoleCountryList()
    {
        try
        {

            var query = conn.Table<CountryInfo>().OrderBy(v=>v.country);
            List<CountryInfo> l = query.ToList<CountryInfo>();
            l = l.OrderBy(x => x.country).ToList();
            return l;
        }
        catch (Exception E)
        { 

            return null; 
        }
    }