Repository navigation
Expand file tree
/
Copy pathSqlCeDialect.cs
More file actions
64 lines (53 loc) · 1.82 KB
/
Copy pathSqlCeDialect.cs
File metadata and controls
64 lines (53 loc) · 1.82 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DapperExtensions.Sql
{
public class SqlCeDialect : SqlDialectBase
{
public override char OpenQuote
{
get { return '['; }
}
public override char CloseQuote
{
get { return ']'; }
}
public override bool SupportsMultipleStatements
{
get { return false; }
}
public override string GetTableName(string schemaName, string tableName, string alias)
{
if (string.IsNullOrWhiteSpace(tableName))
{
throw new ArgumentNullException("TableName");
}
StringBuilder result = new StringBuilder();
result.Append(OpenQuote);
if (!string.IsNullOrWhiteSpace(schemaName))
{
result.AppendFormat("{0}_", schemaName);
}
result.AppendFormat("{0}{1}", tableName, CloseQuote);
if (!string.IsNullOrWhiteSpace(alias))
{
result.AppendFormat(" AS {0}{1}{2}", OpenQuote, alias, CloseQuote);
}
return result.ToString();
}
public override string GetIdentitySql(string tableName)
{
return "SELECT CAST(@@IDENTITY AS BIGINT) AS [Id]";
}
public override string GetPagingSql(string sql, int page, int resultsPerPage, IDictionary<string, object> parameters)
{
string result = string.Format("{0} OFFSET @pageStartRowNbr ROWS FETCH NEXT @resultsPerPage ROWS ONLY", sql);
int startValue = (page * resultsPerPage);
parameters.Add("@pageStartRowNbr", startValue);
parameters.Add("@resultsPerPage", resultsPerPage);
return result;
}
}
}