dotConnect for SQLite Documentation
Devart.Data.SQLite Namespace / SQLiteCollationFunction Class
Members Example

SQLiteCollationFunction Class
Base class for user-defined collation functions.
Syntax
'Declaration
 
Public MustInherit Class SQLiteCollationFunction 
   Inherits SQLiteFunction
   Implements System.IDisposable 
 
Remarks

Use this class to derive classes for user-defined collation functions from it.

Collation functions are used for sorting. You should implement the comparison operation for it.

To register the user-defined collation funtion, create the class, derived from SQLiteCollationFunction and pass its name to the base class constructor.

You should also override Compare method. This method should implement the comparison operation.

Example
Example of the user-defined collation function which implements the string comparison.
public class MyCollation : SQLiteCollationFunction {

        public MyCollation() : base("StringCollation") { }

        protected override int Compare(string param1, string param2, SQLiteConnection connection) {

                return string.Compare(param1, param2);
        }
}

...

SQLiteConnection sqLiteConnection = new SQLiteConnection(@"Data Source=D:\SQLite\test.db");
      sqLiteConnection.Open();
MyCollation collation = new MyCollation();
      sqLiteConnection.RegisterFunction(collation);
SQLiteCommand command = new SQLiteCommand("select * from Dept order by DName collate StringCollation", sqLiteConnection);
      using (SQLiteDataReader rd = command.ExecuteReader()) {
while (rd.Read()) {
        long deptno = rd.GetInt64(0);
        string dname = rd.GetString(1);
        string loc = rd.GetString(2);
}
      }
      sqLiteConnection.UnRegisterFunction(collation);
      sqLiteConnection.Close();
Inheritance Hierarchy

System.Object
   Devart.Data.SQLite.SQLiteFunction
      Devart.Data.SQLite.SQLiteCollationFunction

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also