private SessionHandler CreateSessionHandler() { SqlConnection connection; var connectionIsExternal = false; var transactionIsExternal = false; var upgradeContext = UpgradeContext.GetCurrent(Domain.UpgradeContextCookie); if (upgradeContext != null) { connection = upgradeContext.Services.Connection; connectionIsExternal = true; transactionIsExternal = true; } else if (Domain.SingleConnection != null) { connection = Domain.SingleConnection; connectionIsExternal = true; } else { connection = Handlers.StorageDriver.CreateConnection(this); } return(new SqlSessionHandler(this, connection, connectionIsExternal, transactionIsExternal)); }
/// <summary> /// Compiles the specified SQL DOM query. /// </summary> /// <param name="query">Query to compile.</param> /// <returns>Compiled query.</returns> public SqlCompilationResult CompileQuery(ISqlCompileUnit query) { ArgumentValidator.EnsureArgumentNotNull(query, "query"); var upgradeContext = UpgradeContext.GetCurrent(Session.Domain.UpgradeContextCookie); if (upgradeContext != null) { return(driver.Compile(query, upgradeContext.NodeConfiguration)); } return(driver.Compile(query, Session.StorageNode.Configuration)); }
private string Compile(ISqlCompileUnit statement) { if (session == null) { return(driver.Compile(statement).GetCommandText()); } var upgradeContext = UpgradeContext.GetCurrent(session.Domain.UpgradeContextCookie); if (upgradeContext != null) { return(driver.Compile(statement, upgradeContext.NodeConfiguration).GetCommandText()); } return(driver.Compile(statement, session.StorageNode.Configuration).GetCommandText()); }
/// <inheritdoc/> public Segment <long> NextBulk(SequenceInfo sequenceInfo, Session session) { var executionFromUpgrade = UpgradeContext.GetCurrent(session.Domain.UpgradeContextCookie) != null; var query = GetSequenceQuery(sequenceInfo, session, executionFromUpgrade); long hiValue = Execute(query, session); if (executionFromUpgrade && !hasAISettingsInMemory) { CleanUp(Enumerable.Repeat(sequenceInfo, 1), session); } var increment = sequenceInfo.Increment; var current = hasArbitaryIncrement ? hiValue - increment : (hiValue - 1) * increment; return(new Segment <long>(current + 1, increment)); }