Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD SQLServer 2012 and later Dialect #259

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ADD SQLServer 2012 and later Dialect
  • Loading branch information
wswind committed Dec 3, 2021

Verified

This commit was signed with the committer’s verified signature.
xiaofei-du Xiaofei Du
commit a9e18241fe89918e8ad6086ae187865638b0269c
9 changes: 8 additions & 1 deletion Dapper.SimpleCRUD/SimpleCRUD.cs
Original file line number Diff line number Diff line change
@@ -103,10 +103,16 @@ public static void SetDialect(Dialect dialect)
_getIdentitySql = string.Format("SELECT CAST(IDENTITY_VAL_LOCAL() AS DEC(31,0)) AS \"id\" FROM SYSIBM.SYSDUMMY1");
_getPagedListSql = "Select * from (Select {SelectColumns}, row_number() over(order by {OrderBy}) as PagedNumber from {TableName} {WhereClause} Order By {OrderBy}) as t where t.PagedNumber between (({PageNumber}-1) * {RowsPerPage} + 1) AND ({PageNumber} * {RowsPerPage})";
break;
case Dialect.SQLServer12:
_dialect = Dialect.SQLServer12;
_encapsulation = "[{0}]";
_getIdentitySql = string.Format("SELECT CAST(SCOPE_IDENTITY() AS BIGINT) AS [id]");
_getPagedListSql = "SELECT * FROM {TableName} {WhereClause} ORDER BY {OrderBy} OFFSET (({PageNumber}-1) * {RowsPerPage}) ROWS FETCH NEXT {RowsPerPage} ROWS ONLY";
break;
default:
_dialect = Dialect.SQLServer;
_encapsulation = "[{0}]";
_getIdentitySql = string.Format("SELECT CAST(SCOPE_IDENTITY() AS BIGINT) AS [id]");
_getIdentitySql = string.Format("SELECT CAST(SCOPE_IDENTITY() AS BIGINT) AS [id]");
_getPagedListSql = "SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY {OrderBy}) AS PagedNumber, {SelectColumns} FROM {TableName} {WhereClause}) AS u WHERE PagedNumber BETWEEN (({PageNumber}-1) * {RowsPerPage} + 1) AND ({PageNumber} * {RowsPerPage})";
break;
}
@@ -1005,6 +1011,7 @@ public static Guid SequentialGuid()
public enum Dialect
{
SQLServer,
SQLServer12,
PostgreSQL,
SQLite,
MySQL,