/
PostgreSqlDialect.cs
40 lines (34 loc) · 1.34 KB
/
PostgreSqlDialect.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DapperExtensions.Sql
{
public class PostgreSqlDialect : SqlDialectBase
{
public override string GetIdentitySql(string tableName)
{
return "SELECT LASTVAL() AS Id";
}
public override string GetPagingSql(string sql, int page, int resultsPerPage, IDictionary<string, object> parameters)
{
int startValue = page * resultsPerPage;
return GetSetSql(sql, startValue, resultsPerPage, parameters);
}
public override string GetSetSql(string sql, int firstResult, int maxResults, IDictionary<string, object> parameters)
{
string result = string.Format("{0} LIMIT @firstResult OFFSET @pageStartRowNbr", sql);
parameters.Add("@firstResult", firstResult);
parameters.Add("@maxResults", maxResults);
return result;
}
public override string GetColumnName(string prefix, string columnName, string alias)
{
return base.GetColumnName(null, columnName, alias).ToLower();
}
public override string GetTableName(string schemaName, string tableName, string alias)
{
return base.GetTableName(schemaName, tableName, alias).ToLower();
}
}
}