Skip to content

Commit 5306d64

Browse files
author
Marc Sallin
committed
#42: Added collate attribute.
1 parent 1c12d90 commit 5306d64

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
3+
namespace SQLite.CodeFirst
4+
{
5+
/// <summary>
6+
/// When SQLite compares two strings, it uses a collating sequence or collating function (two words for the same thing)
7+
/// to determine which string is greater or if the two strings are equal. SQLite has three built-in collating functions (see <see cref="CollationFunction"/>).
8+
/// </summary>
9+
[AttributeUsage(AttributeTargets.Property)]
10+
public sealed class CollateAttribute : Attribute
11+
{
12+
public CollateAttribute(CollationFunction collation = CollationFunction.None)
13+
{
14+
Collation = collation;
15+
}
16+
17+
public CollationFunction Collation { get; set; }
18+
}
19+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
namespace SQLite.CodeFirst
2+
{
3+
/// <summary>
4+
/// The collation function to use for this column.
5+
/// Is used together with the <see cref="CollateAttribute" />.
6+
/// </summary>
7+
public enum CollationFunction
8+
{
9+
None,
10+
11+
/// <summary>
12+
/// Compares string data using memcmp(), regardless of text encoding.
13+
/// </summary>
14+
RTrim,
15+
16+
/// <summary>
17+
/// The same as binary, except the 26 upper case characters of ASCII are folded to their lower case equivalents before
18+
/// the comparison is performed. Note that only ASCII characters are case folded. SQLite does not attempt to do full
19+
/// UTF case folding due to the size of the tables required.
20+
/// </summary>
21+
NoCase,
22+
23+
/// <summary>
24+
/// The same as binary, except that trailing space characters are ignored.
25+
/// </summary>
26+
Binary
27+
}
28+
}

SQLite.CodeFirst/SQLite.CodeFirst.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
<Compile Include="..\Shared\AssemblySharedInfo.cs">
8484
<Link>Properties\AssemblySharedInfo.cs</Link>
8585
</Compile>
86+
<Compile Include="Attributes\CollateAttribute.cs" />
87+
<Compile Include="Attributes\CollationFunction.cs" />
8688
<Compile Include="Attributes\OnConflictAction.cs" />
8789
<Compile Include="Attributes\UniqueAttribute.cs" />
8890
<Compile Include="Entities\IHistory.cs" />

0 commit comments

Comments
 (0)