diff --git a/doc/reference/modules/configuration.xml b/doc/reference/modules/configuration.xml index 7e590d4c9d..e39690c2ae 100644 --- a/doc/reference/modules/configuration.xml +++ b/doc/reference/modules/configuration.xml @@ -1606,6 +1606,11 @@ in the parameter binding. NHibernate.Dialect.SybaseASE15Dialect + + Sybase Adaptive Server Enterprise 16 + NHibernate.Dialect.SybaseASE16Dialect + + Sybase SQL Anywhere 10 NHibernate.Dialect.SybaseSQLAnywhere10Dialect diff --git a/src/NHibernate/Dialect/SybaseASE16Dialect.cs b/src/NHibernate/Dialect/SybaseASE16Dialect.cs new file mode 100644 index 0000000000..41aab5fcd0 --- /dev/null +++ b/src/NHibernate/Dialect/SybaseASE16Dialect.cs @@ -0,0 +1,62 @@ +using NHibernate.SqlCommand; + +namespace NHibernate.Dialect +{ + /// + /// An SQL dialect targeting Sybase Adaptive Server Enterprise (ASE) 16 and higher. + /// + /// + /// The dialect defaults the following configuration properties: + /// + /// + /// Property + /// Default Value + /// + /// + /// connection.driver_class + /// + /// + /// + /// + public class SybaseASE16Dialect : SybaseASE15Dialect + { + /// + /// ASE 16 supports limit statements, see https://help.sap.com/docs/SAP_ASE/e0d4539d39c34f52ae9ef822c2060077/26d84b4ddae94fed89d4e7c88bc8d1e6.html?locale=en-US + /// + /// true + public override bool SupportsLimit => true; + + /// + /// true + public override bool SupportsLimitOffset => true; + + /// + /// false + public override bool SupportsVariableLimit => false; + + /// + public override SqlString GetLimitString(SqlString queryString, SqlString offset, SqlString limit) + { + if (offset == null && limit == null) + return queryString; + + var pagingBuilder = new SqlStringBuilder(); + pagingBuilder.Add(queryString); + pagingBuilder.Add(" rows "); + + if (limit != null) + { + pagingBuilder.Add(" limit "); + pagingBuilder.Add(limit); + } + + if (offset != null) + { + pagingBuilder.Add(" offset "); + pagingBuilder.Add(offset); + } + + return pagingBuilder.ToSqlString(); + } + } +}