public OracleTransformationProvider(Dialect dialect, string connectionString) : base(dialect, connectionString) { connection = new OracleConnection(); connection.ConnectionString = base.connectionString; connection.Open(); }
protected TransformationProvider(Dialect dialect, string connectionString, string defaultSchema) { _dialect = dialect; _connectionString = connectionString; _defaultSchema = defaultSchema; _logger = new Logger(false); }
/// <summary> /// Configures the TableGenerator by reading the value of <c>table</c>, /// <c>column</c>, and <c>schema</c> from the <c>parms</c> parameter. /// </summary> /// <param name="type">The <see cref="IType"/> the identifier should be.</param> /// <param name="parms">An <see cref="IDictionary"/> of Param values that are keyed by parameter name.</param> /// <param name="dialect">The <see cref="Dialect.Dialect"/> to help with Configuration.</param> public virtual void Configure( IType type, IDictionary parms, Dialect.Dialect dialect ) { this.tableName = PropertiesHelper.GetString( Table, parms, "hibernate_unique_key" ); this.columnName = PropertiesHelper.GetString( Column, parms, "next_hi" ); string schemaName = ( string ) parms[ Schema ]; if( schemaName != null && tableName.IndexOf( StringHelper.Dot ) < 0 ) { tableName = schemaName + "." + tableName; } query = "select " + columnName + " from " + tableName; if( dialect.SupportsForUpdate ) { query += " for update"; } // build the sql string for the Update since it uses parameters Parameter setParam = new Parameter( columnName, new Int32SqlType() ); Parameter whereParam = new Parameter( columnName, new Int32SqlType() ); SqlStringBuilder builder = new SqlStringBuilder(); builder.Add( "update " + tableName + " set " ) .Add( columnName ) .Add( " = " ) .Add( setParam ) .Add( " where " ) .Add( columnName ) .Add( " = " ) .Add( whereParam ); updateSql = builder.ToSqlString(); }
/// <summary> /// /// </summary> /// <param name="type"></param> /// <param name="parms"></param> /// <param name="d"></param> public void Configure(IType type, IDictionary<string, string> parms, Dialect.Dialect d) { string tableList; string column; string schema; string catalog; if (!parms.TryGetValue("tables", out tableList)) parms.TryGetValue(PersistentIdGeneratorParmsNames.Tables, out tableList); string[] tables = StringHelper.Split(", ", tableList); if (!parms.TryGetValue("column", out column)) parms.TryGetValue(PersistentIdGeneratorParmsNames.PK, out column); returnClass = type.ReturnedClass; parms.TryGetValue(PersistentIdGeneratorParmsNames.Schema, out schema); parms.TryGetValue(PersistentIdGeneratorParmsNames.Catalog, out catalog); StringBuilder buf = new StringBuilder(); for (int i = 0; i < tables.Length; i++) { if (tables.Length > 1) { buf.Append("select ").Append(column).Append(" from "); } buf.Append(Table.Qualify(catalog, schema, tables[i])); if (i < tables.Length - 1) buf.Append(" union "); } if (tables.Length > 1) { buf.Insert(0, "( ").Append(" ) ids_"); column = "ids_." + column; } sql = "select max(" + column + ") from " + buf; }
/// <summary> /// Generates the SQL string to create the named Foreign Key Constraint in the database. /// </summary> /// <param name="d">The <see cref="Dialect.Dialect"/> to use for SQL rules.</param> /// <param name="constraintName">The name to use as the identifier of the constraint in the database.</param> /// <param name="defaultSchema"></param> /// <param name="defaultCatalog"></param> /// <returns> /// A string that contains the SQL to create the named Foreign Key Constraint. /// </returns> public override string SqlConstraintString(Dialect.Dialect d, string constraintName, string defaultCatalog, string defaultSchema) { string[] cols = new string[ColumnSpan]; string[] refcols = new string[ColumnSpan]; int i = 0; IEnumerable<Column> refiter; if (IsReferenceToPrimaryKey) refiter = referencedTable.PrimaryKey.ColumnIterator; else refiter = referencedColumns; foreach (Column column in ColumnIterator) { cols[i] = column.GetQuotedName(d); i++; } i = 0; foreach (Column column in refiter) { refcols[i] = column.GetQuotedName(d); i++; } string result = d.GetAddForeignKeyConstraintString(constraintName, cols, referencedTable.GetQualifiedName(d, defaultCatalog, defaultSchema), refcols, IsReferenceToPrimaryKey); return cascadeDeleteEnabled && d.SupportsCascadeDelete ? result + " on delete cascade" : result; }
protected override bool AppliesTo(Dialect.Dialect dialect) { return !(dialect is Dialect.Oracle8iDialect); // Oracle sometimes causes: ORA-12520: TNS:listener could not find available handler for requested type of server // Following links bizarrely suggest it's an Oracle limitation under load: // http://www.orafaq.com/forum/t/60019/2/ & http://www.ispirer.com/wiki/sqlways/troubleshooting-guide/oracle/import/tns_listener }
protected TransformationProvider(Dialect dialect, string connectionString, string schemaName) { _dialect = dialect; _connectionString = connectionString; _schemaName = schemaName; _logger = new Logger(false); }
/// <summary> /// Configures the SequenceGenerator by reading the value of <c>sequence</c> and /// <c>schema</c> from the <c>parms</c> parameter. /// </summary> /// <param name="type">The <see cref="IType"/> the identifier should be.</param> /// <param name="parms">An <see cref="IDictionary"/> of Param values that are keyed by parameter name.</param> /// <param name="dialect">The <see cref="Dialect.Dialect"/> to help with Configuration.</param> public virtual void Configure(IType type, IDictionary<string, string> parms, Dialect.Dialect dialect) { var nativeSequenceName = PropertiesHelper.GetString(Sequence, parms, "hibernate_sequence"); bool needQuote = StringHelper.IsBackticksEnclosed(nativeSequenceName); bool isQuelified = nativeSequenceName.IndexOf('.') > 0; if (isQuelified) { string qualifier = StringHelper.Qualifier(nativeSequenceName); nativeSequenceName = StringHelper.Unqualify(nativeSequenceName); nativeSequenceName = StringHelper.PurgeBackticksEnclosing(nativeSequenceName); sequenceName = qualifier + '.' + (needQuote ? dialect.QuoteForTableName(nativeSequenceName) : nativeSequenceName); } else { nativeSequenceName = StringHelper.PurgeBackticksEnclosing(nativeSequenceName); sequenceName = needQuote ? dialect.QuoteForTableName(nativeSequenceName) : nativeSequenceName; } string schemaName; string catalogName; parms.TryGetValue(Parameters, out parameters); parms.TryGetValue(PersistentIdGeneratorParmsNames.Schema, out schemaName); parms.TryGetValue(PersistentIdGeneratorParmsNames.Catalog, out catalogName); if (!isQuelified) { sequenceName = dialect.Qualify(catalogName, schemaName, sequenceName); } identifierType = type; sql = new SqlString(dialect.GetSequenceNextValString(sequenceName)); }
/// <summary> /// Configures the TableHiLoGenerator by reading the value of <c>table</c>, /// <c>column</c>, <c>max_lo</c>, and <c>schema</c> from the <c>parms</c> parameter. /// </summary> /// <param name="type">The <see cref="IType"/> the identifier should be.</param> /// <param name="parms">An <see cref="IDictionary"/> of Param values that are keyed by parameter name.</param> /// <param name="dialect">The <see cref="Dialect.Dialect"/> to help with Configuration.</param> public override void Configure(IType type, IDictionary<string, string> parms, Dialect.Dialect dialect) { base.Configure(type, parms, dialect); maxLo = PropertiesHelper.GetInt64(MaxLo, parms, Int16.MaxValue); lo = maxLo + 1; // so we "clock over" on the first invocation returnClass = type.ReturnedClass; }
/// <summary> /// Get the SQL string to drop this Constraint in the database. /// </summary> /// <param name="dialect">The <see cref="Dialect.Dialect"/> to use for SQL rules.</param> /// <param name="defaultCatalog"></param> /// <param name="defaultSchema"></param> /// <returns> /// A string that contains the SQL to drop this Constraint. /// </returns> public override string SqlDropString(Dialect.Dialect dialect, string defaultCatalog, string defaultSchema) { string ifExists = dialect.GetIfExistsDropConstraint(Table, Name); string drop = string.Format("alter table {0}{1}", Table.GetQualifiedName(dialect, defaultCatalog, defaultSchema), dialect.GetDropPrimaryKeyConstraintString(Name)); string end = dialect.GetIfExistsDropConstraintEnd(Table, Name); return ifExists + Environment.NewLine + drop + Environment.NewLine + end; }
public override string SqlCreateString( Dialect.Dialect dialect, IMapping p, string defaultSchema) { return InjectCatalogAndSchema(sqlCreateString, defaultSchema); }
/// <summary> Build a SQLExceptionConverter instance. </summary> /// <param name="dialect">The defined dialect. </param> /// <param name="properties">The configuration properties. </param> /// <returns> An appropriate <see cref="ISQLExceptionConverter"/> instance. </returns> /// <remarks> /// First, looks for a <see cref="Cfg.Environment.SqlExceptionConverter"/> property to see /// if the configuration specified the class of a specific converter to use. If this /// property is set, attempt to construct an instance of that class. If not set, or /// if construction fails, the converter specific to the dialect will be used. /// </remarks> public static ISQLExceptionConverter BuildSQLExceptionConverter(Dialect.Dialect dialect, IDictionary<string, string> properties) { ISQLExceptionConverter converter = null; string converterClassName; properties.TryGetValue(Cfg.Environment.SqlExceptionConverter, out converterClassName); if (!string.IsNullOrEmpty(converterClassName)) { converter = ConstructConverter(converterClassName, dialect.ViolatedConstraintNameExtracter); } if (converter == null) { log.Info("Using dialect defined converter"); converter = dialect.BuildSQLExceptionConverter(); } IConfigurable confConv = converter as IConfigurable; if (confConv != null) { try { confConv.Configure(properties); } catch (HibernateException e) { log.Warn("Unable to configure SQLExceptionConverter", e); throw; } } return converter; }
public MySqlTransformationProvider(Dialect dialect, string connectionString) : base(dialect, connectionString) { connection = new MySqlConnection(base.connectionString); connection.ConnectionString = base.connectionString; connection.Open(); }
public static string ParseToString(object o, Dialect.DbDialect dd) { if (o == null) { return "NULL"; } var ot = o.GetType(); if ( typeof(bool) == ot ) { return Convert.ToInt32(o).ToString(); } if ( typeof(string) == ot ) { string s = o.ToString(); s = s.Replace("'", "''"); return string.Format("N'{0}'", s); } if ( typeof(DateTime) == ot || typeof(Date) == ot || typeof(Time) == ot ) { return dd.QuoteDateTimeValue(o.ToString()); } if (ot.IsEnum) { return Convert.ToInt32(o).ToString(); } if (typeof(byte[]) == ot) { throw new ApplicationException("Sql without Parameter can not support blob, please using Parameter mode."); } return o.ToString(); }
public SelectBuilder(Dialect dialect, string[] tables, string[] columns) { _dialect = dialect; _tables = tables; _columns = columns; Parameters = new In[0]; }
public OracleManagedDriverTransformationProvider(Dialect dialect, string connectionString, string defaultSchema) : base(dialect, connectionString, defaultSchema) { _connection = new OracleConnection(); _connection.ConnectionString = _connectionString; _connection.Open(); }
public MappingRootBinder(Mappings mappings, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect) : base(mappings) { this.namespaceManager = namespaceManager; this.dialect = dialect; }
public DatabaseMetadata(DbConnection connection, Dialect.Dialect dialect, bool extras) { schemaReader = new InformationSchemaReader(connection); this.extras = extras; InitSequences(connection, dialect); sqlExceptionConverter = dialect.BuildSQLExceptionConverter(); }
/// <summary> /// Gets the schema qualified name of the Table using the specified qualifier /// </summary> /// <param name="dialect">The <see cref="Dialect.Dialect"/> that knows how to Quote the Table name.</param> /// <param name="defaultQualifier">The Qualifier to use when accessing the table.</param> /// <returns>A String representing the Qualified name.</returns> /// <remarks>If this were used with MSSQL it would return a dbo.table_name.</remarks> public string GetQualifiedName( Dialect.Dialect dialect, string defaultQualifier ) { string quotedName = GetQuotedName( dialect ); return schema == null ? ( ( defaultQualifier == null ) ? quotedName : defaultQualifier + StringHelper.Dot + quotedName ) : GetQualifiedName( dialect ); }
public static string BuildSqlDropIndexString(Dialect.Dialect dialect, Table table, string name, string defaultCatalog, string defaultSchema) { string ifExists = dialect.GetIfExistsDropConstraint(table, name); string drop = string.Format("drop index {0}", StringHelper.Qualify(table.GetQualifiedName(dialect, defaultCatalog, defaultSchema), name)); string end = dialect.GetIfExistsDropConstraintEnd(table, name); return ifExists + Environment.NewLine + drop + Environment.NewLine + end; }
public PostgreSQLTransformationProvider(Dialect dialect, string connectionString) : base(dialect, connectionString) { connection = new NpgsqlConnection(); connection.ConnectionString = connectionString; connection.Open(); }
public virtual void Configure(IType type, IDictionary<string, string> parms, Dialect.Dialect dialect) { IdentifierType = type; bool forceTableUse = PropertiesHelper.GetBoolean(ForceTableParam, parms, false); string sequenceName = DetermineSequenceName(parms, dialect); int initialValue = DetermineInitialValue(parms); int incrementSize = DetermineIncrementSize(parms); string optimizationStrategy = DetermineOptimizationStrategy(parms, incrementSize); incrementSize = DetermineAdjustedIncrementSize(optimizationStrategy, incrementSize); Optimizer = OptimizerFactory.BuildOptimizer( optimizationStrategy, IdentifierType.ReturnedClass, incrementSize, PropertiesHelper.GetInt32(InitialParam, parms, -1)); // Use -1 as default initial value here to signal that it's not set. if (!forceTableUse && RequiresPooledSequence(initialValue, incrementSize, Optimizer) && !dialect.SupportsPooledSequences) { // force the use of a table (overriding whatever the user configured) since the dialect // doesn't support the sequence features we need. forceTableUse = true; Log.Info("Forcing table use for sequence-style generator due to optimizer selection where db does not support pooled sequences."); } DatabaseStructure = BuildDatabaseStructure(type, parms, dialect, forceTableUse, sequenceName, initialValue, incrementSize); DatabaseStructure.Prepare(Optimizer); }
public SequenceStructure(Dialect.Dialect dialect, string sequenceName, int initialValue, int incrementSize) { _sequenceName = sequenceName; _initialValue = initialValue; _incrementSize = incrementSize; _sql = new SqlString(dialect.GetSequenceNextValString(sequenceName)); }
/// <summary> /// Configures the ForeignGenerator by reading the value of <c>property</c> /// from the <c>parms</c> parameter. /// </summary> /// <param name="type">The <see cref="IType"/> the identifier should be.</param> /// <param name="parms">An <see cref="IDictionary"/> of Param values that are keyed by parameter name.</param> /// <param name="d">The <see cref="Dialect.Dialect"/> to help with Configuration.</param> /// <exception cref="MappingException"> /// Thrown if the key <c>property</c> is not found in the <c>parms</c> parameter. /// </exception> public void Configure(IType type, IDictionary<string, string> parms, Dialect.Dialect d) { parms.TryGetValue("property", out propertyName); if (string.IsNullOrEmpty(propertyName)) { throw new MappingException("param named \"property\" is required for foreign id generation strategy"); } }
public virtual string[] SqlCreateStrings(Dialect.Dialect dialect) { return new String[] { "create table " + tableName + " ( " + valueColumnName + " " + dialect.GetTypeName(SqlTypeFactory.Int64) + " )", "insert into " + tableName + " values ( " + initialValue + " )" }; }
public void Configure(IType type, IDictionary<string, string> parms, Dialect.Dialect dialect) { parms.TryGetValue(IdGeneratorParmsNames.EntityName, out entityName); if (entityName == null) { throw new MappingException("no entity name"); } }
/// <summary> /// Configures the ForeignGenerator by reading the value of <c>property</c> /// from the <c>parms</c> parameter. /// </summary> /// <param name="type">The <see cref="IType"/> the identifier should be.</param> /// <param name="parms">An <see cref="IDictionary"/> of Param values that are keyed by parameter name.</param> /// <param name="d">The <see cref="Dialect.Dialect"/> to help with Configuration.</param> /// <exception cref="MappingException"> /// Thrown if the key <c>property</c> is not found in the <c>parms</c> parameter. /// </exception> public void Configure( IType type, IDictionary parms, Dialect.Dialect d ) { propertyName = ( string ) parms[ "property" ]; if( propertyName == null || propertyName.Length == 0 ) { throw new MappingException( "param named \"property\" is required for foreign id generation strategy" ); } }
public static TestDialect GetTestDialect(Dialect.Dialect dialect) { string testDialectTypeName = "NHibernate.Test.TestDialects." + dialect.GetType().Name.Replace("Dialect", "TestDialect"); System.Type testDialectType = System.Type.GetType(testDialectTypeName); if (testDialectType != null) return (TestDialect)Activator.CreateInstance(testDialectType, dialect); return new TestDialect(dialect); }
public DatabaseMetadata(DbConnection connection, Dialect.Dialect dialect, bool extras) { meta = dialect.GetDataBaseSchema(connection); this.dialect = dialect; this.extras = extras; InitSequences(connection, dialect); sqlExceptionConverter = dialect.BuildSQLExceptionConverter(); }
public IngresTransformationProvider(Dialect dialect, string connectionString, string scope, string providerName) : base(dialect, connectionString, null, scope) { if (string.IsNullOrEmpty(providerName)) providerName = "Ingres.Client"; var fac = DbProviderFactories.GetFactory(providerName); _connection = fac.CreateConnection(); _connection.ConnectionString = _connectionString; this._connection.Open(); }
public async Task FilestreamEffectiveLevel_PropertyGet_ThrowsNothing() { var serverProps = await Dialect.GetServerProperties2008(Config.ConnectionFactory).ConfigureAwait(false); Assert.That(() => serverProps.FilestreamEffectiveLevel, Throws.Nothing); }
public void Nolock() { Assert.Throws <NotSupportedException>(() => Dialect.SetNolock("")); }
public EnumTests(Dialect dialect) : base(dialect) { }
public EnumAsIntAsPkTests(Dialect dialect) : base(dialect) { }
public void SchemaAndTable_ReturnsProperlyQuoted() { string result = Dialect.GetTableName("bar", "foo", null); Assert.AreEqual("[bar_foo]", result); }
private static void RegisterFunction(Dialect dialect, String name, ISQLFunction function) { registerFunctionMethod.Invoke(dialect, new Object[] { name, function }); }
public string[] SqlDropString(Dialect dialect) { return(new [] { dialect.GetDropTableString(tableName) }); }
public DatabaseOperations(string connectionString, Dialect dialect) { this.connectionString = connectionString; this.dialect = dialect; }
public override ITransformationProvider GetTransformationProvider(Dialect dialect, string connectionString, string defaultSchema, string scope, string providerName) { return(new MariaDBTransformationProvider(dialect, connectionString, scope, providerName)); }
public async Task IsIntegratedSecurityOnly_PropertyGet_IsNotNull() { var serverProps = await Dialect.GetServerProperties2008(Config.ConnectionFactory).ConfigureAwait(false); Assert.That(serverProps.IsIntegratedSecurityOnly, Is.Not.Null); }
public async Task IsFullTextInstalled_PropertyGet_IsNotNull() { var serverProps = await Dialect.GetServerProperties2008(Config.ConnectionFactory).ConfigureAwait(false); Assert.That(serverProps.IsFullTextInstalled, Is.Not.Null); }
public async Task NumLicenses_PropertyGet_IsNull() { var serverProps = await Dialect.GetServerProperties2008(Config.ConnectionFactory).ConfigureAwait(false); Assert.That(serverProps.NumLicenses, Is.Null); }
public async Task ResourceLastUpdateDateTime_PropertyGet_IsNotNull() { var serverProps = await Dialect.GetServerProperties2008(Config.ConnectionFactory).ConfigureAwait(false); Assert.That(() => serverProps.ResourceLastUpdateDateTime, Throws.Nothing); }
public async Task Collation_PropertyGet_IsNotNull() { var serverProps = await Dialect.GetServerProperties2008(Config.ConnectionFactory).ConfigureAwait(false); Assert.That(serverProps.Collation, Is.Not.Null); }
public async Task GetDatabaseVersionAsync_GivenValidConnection_ReturnsNonNullVersion() { var version = await Dialect.GetDatabaseVersionAsync(Connection).ConfigureAwait(false); Assert.That(version, Is.Not.Null); }
public OracleTransformationProvider(Dialect dialect, string connectionString) : base(dialect, connectionString) { _connection = new OracleConnection(); _connection.ConnectionString = _connectionString; }
public IncorrectIndexDetector(Configuration configuration) { this.dialect = Dialect.GetDialect(configuration.Properties); this.connectionHelper = new ManagedProviderConnectionHelper(MergeProperties(configuration.Properties)); this.timeoutEntityMapping = configuration.GetClassMapping(typeof(TimeoutEntity)); }
public OrmLiteTestBase(Dialect dialect) { Dialect = dialect; Init(); }
public void Configure(IType type, IDictionary <string, string> parms, Dialect dialect) { tableName = PropertiesHelper.GetString(TableParamName, parms, DefaultTableName); columnName = PropertiesHelper.GetString(ColumnParamName, parms, DefaultColumnName); whereColumn = PropertiesHelper.GetString(WhereColumn, parms, DefaultWhereColumnName); whereValue = PropertiesHelper.GetString(WhereValue, parms, string.Empty); max_lo = PropertiesHelper.GetInt64(MaxLo, parms, Int16.MaxValue); lo = max_lo + 1; returnClass = type.ReturnedClass; if (string.IsNullOrEmpty(whereValue)) { log.Error("wherevalue for SingleTableHiLoGenerator is empty"); throw new InvalidOperationException("wherevalue is empty"); } whereValues.Add(whereValue); var schemaName = PropertiesHelper.GetString(PersistentIdGeneratorParmsNames.Schema, parms, null); var catalogName = PropertiesHelper.GetString(PersistentIdGeneratorParmsNames.Catalog, parms, null); if (tableName.IndexOf('.') < 0) { tableName = dialect.Qualify(catalogName, schemaName, tableName); } var selectBuilder = new SqlStringBuilder(100); selectBuilder.Add("select " + columnName) .Add(" from " + dialect.AppendLockHint(LockMode.Upgrade, tableName)) .Add(" where ") .Add(whereColumn).Add("=").Add(whereValue); selectBuilder.Add(dialect.ForUpdateString); query = selectBuilder.ToString(); columnType = type as PrimitiveType; if (columnType == null) { log.Error("Column type for TableGenerator is not a value type"); throw new ArgumentException("type is not a ValueTypeType", "type"); } // build the sql string for the Update since it uses parameters if (type is Int16Type) { columnSqlType = SqlTypeFactory.Int16; } else if (type is Int64Type) { columnSqlType = SqlTypeFactory.Int64; } else { columnSqlType = SqlTypeFactory.Int32; } wherecolumnSqlType = SqlTypeFactory.GetString(255); parameterTypes = new[] { columnSqlType, columnSqlType }; var builder = new SqlStringBuilder(100); builder.Add("update " + tableName + " set ") .Add(columnName).Add("=").Add(Parameter.Placeholder) .Add(" where ") .Add(columnName).Add("=").Add(Parameter.Placeholder) .Add(" and ") .Add(whereColumn).Add("=").Add(whereValue); updateSql = builder.ToSqlString(); }
public override ITransformationProvider GetTransformationProvider(Dialect dialect, string connectionString, string defaultSchema) { return(new OracleTransformationProvider(dialect, connectionString, defaultSchema)); }
public CompositeKeyTests(Dialect dialect) : base(dialect) { }
public override string ObjectToSQLString(object value, Dialect dialect) { return(value.ToString()); }
public void AllParams_ReturnsProperlyQuoted() { string result = Dialect.GetTableName("bar", "foo", "al"); Assert.AreEqual("[bar_foo] AS [al]", result); }
public SentenceSplitter(Dialect dialect) { this.dialect = dialect; }
public void TableNameOnly_ReturnsProperlyQuoted() { string result = Dialect.GetTableName(null, "foo", null); Assert.AreEqual("[foo]", result); }
/// <summary></summary> public SqlString ToSqlString() { // 4 = the "SELECT", selectClause, "FROM", fromClause are straight strings // plus the number of parts in outerJoinsAfterFrom SqlString. // 1 = the "WHERE" // plus the number of parts in outerJoinsAfterWhere SqlString. // 1 = the whereClause // 2 = the "ORDER BY" and orderByClause var joinAfterFrom = outerJoinsAfterFrom != null ? outerJoinsAfterFrom.Count : 0; var joinAfterWhere = outerJoinsAfterWhere != null ? outerJoinsAfterWhere.Count : 0; int initialCapacity = 4 + joinAfterFrom + 1 + joinAfterWhere + 1 + 2; if (!string.IsNullOrEmpty(comment)) { initialCapacity++; } SqlStringBuilder sqlBuilder = new SqlStringBuilder(initialCapacity + 2); if (!string.IsNullOrEmpty(comment)) { sqlBuilder.Add("/* " + comment + " */ "); } sqlBuilder.Add("SELECT ") .Add(selectClause) .Add(" FROM ") .Add(fromClause); if (StringHelper.IsNotEmpty(outerJoinsAfterFrom)) { sqlBuilder.Add(outerJoinsAfterFrom); } if (StringHelper.IsNotEmpty(whereClause) || StringHelper.IsNotEmpty(outerJoinsAfterWhere)) { sqlBuilder.Add(" WHERE "); // the outerJoinsAfterWhere needs to come before where clause to properly // handle dynamic filters if (StringHelper.IsNotEmpty(outerJoinsAfterWhere)) { sqlBuilder.Add(outerJoinsAfterWhere); if (StringHelper.IsNotEmpty(whereClause)) { sqlBuilder.Add(" AND "); } } if (StringHelper.IsNotEmpty(whereClause)) { sqlBuilder.Add(whereClause); } } if (StringHelper.IsNotEmpty(groupByClause)) { sqlBuilder.Add(" GROUP BY ") .Add(groupByClause); } if (StringHelper.IsNotEmpty(havingClause)) { sqlBuilder.Add(" HAVING ") .Add(havingClause); } if (StringHelper.IsNotEmpty(orderByClause)) { sqlBuilder.Add(" ORDER BY ") .Add(orderByClause); } if (lockMode != null) { sqlBuilder.Add(Dialect.GetForUpdateString(lockMode)); } if (log.IsDebugEnabled) { if (initialCapacity < sqlBuilder.Count) { log.Debug( "The initial capacity was set too low at: " + initialCapacity + " for the SelectSqlBuilder " + "that needed a capacity of: " + sqlBuilder.Count + " for the table " + fromClause); } else if (initialCapacity > 16 && ((float)initialCapacity / sqlBuilder.Count) > 1.2) { log.Debug( "The initial capacity was set too high at: " + initialCapacity + " for the SelectSqlBuilder " + "that needed a capacity of: " + sqlBuilder.Count + " for the table " + fromClause); } } return(sqlBuilder.ToSqlString()); }
public CompositeIndexNamingStrategyIssue(Dialect dialect) : base(dialect) { }
public ARSchemaCreator(Configuration config) { this.connectionProperties = config.Properties; this.dialect = Dialect.GetDialect(connectionProperties); }
public async Task FilestreamShareName_PropertyGet_IsNotNull() { var serverProps = await Dialect.GetServerProperties2008(Config.ConnectionFactory).ConfigureAwait(false); Assert.That(serverProps.FilestreamShareName, Is.Not.Null); }
public async Task SqlSortOrder_PropertyGet_IsNotZero() { var serverProps = await Dialect.GetServerProperties2008(Config.ConnectionFactory).ConfigureAwait(false); Assert.That(serverProps.SqlSortOrder, Is.Not.Zero); }