SQLite Chinese sorting and sqlite sorting
Reference page:
Http://www.yuanjiaocheng.net/CSharp/Csharp-Generics-Constraints.html
Http://www.yuanjiaocheng.net/CSharp/Csharp-Generics-collection.html
Http://www.yuanjiaocheng.net/CSharp/Csharp-list-fanx.html
Http://www.yuanjiaocheng.net/CSharp/csharp-generic-sortlist.html
Http://www.yuanjiaocheng.net/CSharp/csharp-generic-dictionary.html
Define a class:
Using System. data. SQLite; namespace DAL {// <summary> // SQLite Chinese sorting // </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
Add the following code to the Application_Start method of the Global. asax. cs file:
SQLiteFunction. RegisterFunction (typeof (SQLitePinYingSort); // enables SQLite to support Chinese sorting
SQL code:
select ct.* from mas_channel_type ct where ct.pId=-1order by ct.typeName COLLATE PinYin
View Code