文章出處

定義一個類:

using System.Data.SQLite;

namespace DAL
{
    /// <summary>
    /// SQLite中文排序
    /// </summary>
    [SQLiteFunction(FuncType = FunctionType.Collation, Name = "PinYin")]
    public class SQLitePinYingSort : SQLiteFunction
    {
        public override int Compare(string x, string y)
        {
            return string.Compare(x, y);
        }
    }
}
View Code

在Global.asax.cs文件的Application_Start方法中添加如下代碼:

SQLiteFunction.RegisterFunction(typeof(SQLitePinYingSort)); //使SQLite支持中文排序

SQL代碼:

select ct.* 
from mas_channel_type ct 
where ct.pId=-1
order by ct.typeName COLLATE PinYin
View Code

 


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


全站熱搜
創作者介紹
創作者 大師兄 的頭像
大師兄

IT工程師數位筆記本

大師兄 發表在 痞客邦 留言(0) 人氣()