Repository navigation
Expand file tree
/
Copy pathSqliteDialect.cs
More file actions
48 lines (43 loc) · 1.5 KB
/
Copy pathSqliteDialect.cs
File metadata and controls
48 lines (43 loc) · 1.5 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
using System;
using System.Collections.Generic;
using System.Text;
namespace DapperExtensions.Sql
{
public class SqliteDialect : SqlDialectBase
{
public override string GetIdentitySql(string tableName)
{
return "SELECT LAST_INSERT_ROWID() AS [Id]";
}
public override string GetPagingSql(string sql, int page, int resultsPerPage, IDictionary<string, object> parameters)
{
if (string.IsNullOrEmpty(sql))
{
throw new ArgumentNullException("SQL");
}
if (parameters == null)
{
throw new ArgumentNullException("Parameters");
}
var result = string.Format("{0} LIMIT @Offset, @Count", sql);
int startValue = page * resultsPerPage;
parameters.Add("@Offset", startValue);
parameters.Add("@Count", resultsPerPage);
return result;
}
public override string GetColumnName(string prefix, string columnName, string alias)
{
if (string.IsNullOrWhiteSpace(columnName))
{
throw new ArgumentNullException(columnName, "columnName cannot be null or empty.");
}
var result = new StringBuilder();
result.AppendFormat(columnName);
if (!string.IsNullOrWhiteSpace(alias))
{
result.AppendFormat(" AS {0}", QuoteString(alias));
}
return result.ToString();
}
}
}