-
-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathCollation.cs
46 lines (39 loc) · 1.79 KB
/
Collation.cs
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
43
44
45
46
using System;
namespace SQLite.CodeFirst
{
/// <summary>
/// This class can be used to specify the default collation for the database. Explicit Collate attributes will take precendence.
/// When SQLite compares two strings, it uses a collating sequence or collating function (two words for the same thing)
/// to determine which string is greater or if the two strings are equal. SQLite has three built-in collating functions (see <see cref="Function"/>).
/// Set <see cref="Function"/> to <see cref="CollationFunction.Custom"/> and specify the name using the function parameter.
/// </summary>
public class Collation
{
public Collation()
: this(CollationFunction.None)
{
}
public Collation(CollationFunction function)
: this(function, null)
{
}
public Collation(CollationFunction function, string customFunction)
{
if (function != CollationFunction.Custom && !string.IsNullOrEmpty(customFunction))
{
throw new ArgumentException("If the collation is not set to CollationFunction.Custom a function must not be specified.", nameof(function));
}
if (function == CollationFunction.Custom && string.IsNullOrEmpty(customFunction))
{
throw new ArgumentException("If the collation is set to CollationFunction.Custom a function must be specified.", nameof(function));
}
CustomFunction = customFunction;
Function = function;
}
public CollationFunction Function { get; set; }
/// <summary>
/// The name of the custom collating function to use (CollationFunction.Custom).
/// </summary>
public string CustomFunction { get; set; }
}
}