|
| 1 | +using NHibernate.SqlCommand; |
| 2 | + |
| 3 | +namespace NHibernate.Dialect |
| 4 | +{ |
| 5 | + /// <summary> |
| 6 | + /// An SQL dialect targeting Sybase Adaptive Server Enterprise (ASE) 16 and higher. |
| 7 | + /// </summary> |
| 8 | + /// <remarks> |
| 9 | + /// The dialect defaults the following configuration properties: |
| 10 | + /// <list type="table"> |
| 11 | + /// <listheader> |
| 12 | + /// <term>Property</term> |
| 13 | + /// <description>Default Value</description> |
| 14 | + /// </listheader> |
| 15 | + /// <item> |
| 16 | + /// <term>connection.driver_class</term> |
| 17 | + /// <description><see cref="NHibernate.Driver.SybaseAseClientDriver" /></description> |
| 18 | + /// </item> |
| 19 | + /// </list> |
| 20 | + /// </remarks> |
| 21 | + public class SybaseASE16Dialect : SybaseASE15Dialect |
| 22 | + { |
| 23 | + /// <summary> |
| 24 | + /// ASE 16 supports limit statements, see https://help.sap.com/docs/SAP_ASE/e0d4539d39c34f52ae9ef822c2060077/26d84b4ddae94fed89d4e7c88bc8d1e6.html?locale=en-US |
| 25 | + /// </summary> |
| 26 | + /// <returns>true</returns> |
| 27 | + public override bool SupportsLimit => true; |
| 28 | + |
| 29 | + /// <inheritdoc /> |
| 30 | + /// <returns>true</returns> |
| 31 | + public override bool SupportsLimitOffset => true; |
| 32 | + |
| 33 | + /// <inheritdoc /> |
| 34 | + /// <returns>false</returns> |
| 35 | + public override bool SupportsVariableLimit => false; |
| 36 | + |
| 37 | + /// <inheritdoc /> |
| 38 | + public override SqlString GetLimitString(SqlString queryString, SqlString offset, SqlString limit) |
| 39 | + { |
| 40 | + if (offset == null && limit == null) |
| 41 | + return queryString; |
| 42 | + |
| 43 | + var pagingBuilder = new SqlStringBuilder(); |
| 44 | + pagingBuilder.Add(queryString); |
| 45 | + pagingBuilder.Add(" rows "); |
| 46 | + |
| 47 | + if (limit != null) |
| 48 | + { |
| 49 | + pagingBuilder.Add(" limit "); |
| 50 | + pagingBuilder.Add(limit); |
| 51 | + } |
| 52 | + |
| 53 | + if (offset != null) |
| 54 | + { |
| 55 | + pagingBuilder.Add(" offset "); |
| 56 | + pagingBuilder.Add(offset); |
| 57 | + } |
| 58 | + |
| 59 | + return pagingBuilder.ToSqlString(); |
| 60 | + } |
| 61 | + } |
| 62 | +} |
0 commit comments