forked from dotnet/efcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
42 lines (36 loc) · 1.2 KB
/
Copy pathProgram.cs
File metadata and controls
42 lines (36 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using Microsoft.Data.Sqlite;
namespace CollationSample
{
class Program
{
static void Main()
{
var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
var createCommand = connection.CreateCommand();
createCommand.CommandText =
@"
CREATE TABLE greek_letter (
value TEXT
);
INSERT INTO greek_letter
VALUES ('Λ'),
('λ');
";
createCommand.ExecuteNonQuery();
// Without this, the query returns one since the built-in NOCASE collation only
// handles ASCII characters (A-Z)
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 count = (long)queryCommand.ExecuteScalar();
Console.WriteLine($"Results: {count}");
}
}
}