Training
Module
Store local data with SQLite in a .NET MAUI app - Training
Learn how to store and access data held in SQLite using a .NET Multi-platform App UI (MAUI) app
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Collating sequences are used by SQLite when comparing TEXT values to determine order and equality. You can specify which collation to use when creating columns or per-operation in SQL queries. SQLite includes three collating sequences by default.
Collation | Description |
---|---|
RTRIM | Ignores trailing whitespace |
NOCASE | Case-insensitive for ASCII characters A-Z |
BINARY | Case-sensitive. Compares bytes directly |
You can also define your own collating sequences or override the built-in ones using CreateCollation. The following example shows overriding the NOCASE collation to support Unicode characters. The full sample code is available on GitHub.
connection.CreateCollation("NOCASE", (x, y) => string.Compare(x, y, ignoreCase: true));
var queryCommand = connection.CreateCommand();
queryCommand.CommandText =
@"
SELECT count()
FROM greek_letter
WHERE value = 'λ' COLLATE NOCASE
";
var oCount = queryCommand.ExecuteScalar();
var count = (oCount is not null) ? (int)oCount : -1;
The LIKE operator in SQLite doesn't honor collations. The default implementation has the same semantics as the NOCASE collation. It's only case-insensitive for the ASCII characters A through Z.
You can easily make the LIKE operator case-sensitive by using the following pragma statement:
PRAGMA case_sensitive_like = 1
See User-defined functions for details on overriding the implementation of the LIKE operator.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Training
Module
Store local data with SQLite in a .NET MAUI app - Training
Learn how to store and access data held in SQLite using a .NET Multi-platform App UI (MAUI) app