public Bootstrap(IDbConnection dbConnection) { lock (_lockObject) { if (!EntityMapper.Entities.Keys.Any()) { var assembliesOfModelTypes = new[] { Assembly.Load("FluentSql.Tests") }; var store = new EntityStore(dbConnection); var fluentTestDb = new Database { Name = TestConstants.TestDatabaseName, TableNamesInPlural = true, NameSpace = "FluentSql.Tests.Models" }; var sqlGenerator = new SqlServerSqlGenerator(includeDbNameInQuery: true); var databases = new List <Database> { fluentTestDb }; store.ExecuteScript(SqlScripts.CREATE_DATABASE, null, false, CommandType.Text); store.ExecuteScript(SqlScripts.CREATE_TABLES, null, false, CommandType.Text); new EntityMapper(dbConnection, databases, assembliesOfModelTypes, null, onPostEntityMapping, null); } } }
private static IHistoryRepository CreateHistoryRepository() { var annotationsProvider = new SqlServerAnnotationProvider(); var sqlGenerator = new SqlServerSqlGenerator(); var typeMapper = new SqlServerTypeMapper(); var commandBuilderFactory = new RelationalCommandBuilderFactory( typeMapper); return(new SqlServerHistoryRepository( Mock.Of <IRelationalDatabaseCreator>(), Mock.Of <ISqlStatementExecutor>(), Mock.Of <ISqlServerConnection>(), new DbContextOptions <DbContext>( new Dictionary <Type, IDbContextOptionsExtension> { { typeof(SqlServerOptionsExtension), new SqlServerOptionsExtension() } }), new MigrationsModelDiffer( annotationsProvider, new SqlServerMigrationsAnnotationProvider()), new SqlServerMigrationsSqlGenerator( commandBuilderFactory, new SqlServerSqlGenerator(), typeMapper, annotationsProvider), annotationsProvider, sqlGenerator)); }
private IList <long>[] GenerateValuesInMultipleThreads(int poolSize, int threadCount, int valueCount) { const int blockSize = 10; var serviceProvider = SqlServerTestHelpers.Instance.CreateServiceProvider(); var state = new SqlServerSequenceValueGeneratorState("Foo", blockSize, poolSize); var executor = new FakeSqlStatementExecutor(blockSize); var sqlGenerator = new SqlServerSqlGenerator(); var tests = new Action[threadCount]; var generatedValues = new List <long> [threadCount]; for (var i = 0; i < tests.Length; i++) { var testNumber = i; generatedValues[testNumber] = new List <long>(); tests[testNumber] = () => { for (var j = 0; j < valueCount; j++) { var connection = CreateConnection(serviceProvider); var generator = new SqlServerSequenceValueGenerator <long>(executor, sqlGenerator, state, connection); generatedValues[testNumber].Add(generator.Next()); } }; } Parallel.Invoke(tests); return(generatedValues); }
/// <summary> /// 生成 SqlServer 可用的测试 Sql 语句。 /// </summary> /// <param name="node"></param> /// <returns></returns> public static FormattedSql GenerateTestSql(IQueryNode node) { var generator = new SqlServerSqlGenerator { AutoQuota = false }; generator.Generate(node as SqlNode); return(generator.Sql); }
public SqlServerModificationCommandBatch([NotNull] SqlServerSqlGenerator sqlGenerator, [CanBeNull] int?maxBatchSize) : base(sqlGenerator) { if (maxBatchSize.HasValue && maxBatchSize.Value <= 0) { throw new ArgumentOutOfRangeException("maxBatchSize", Strings.FormatMaxBatchSizeMustBePositive()); } _maxBatchSize = maxBatchSize; }
public SqlServerModificationCommandBatch([NotNull] SqlServerSqlGenerator sqlGenerator, [CanBeNull] int?maxBatchSize) : base(sqlGenerator) { if (maxBatchSize.HasValue && maxBatchSize.Value <= 0) { throw new ArgumentOutOfRangeException("maxBatchSize", RelationalStrings.InvalidCommandTimeout); } _maxBatchSize = Math.Min(maxBatchSize ?? Int32.MaxValue, MaxRowCount); }
public SqlServerModificationCommandBatchFactory( [NotNull] SqlServerSqlGenerator sqlGenerator, [CanBeNull] IEnumerable <IConfiguration> configurations) : base(sqlGenerator) { var configuration = (configurations == null ? null : configurations.FirstOrDefault()); string maxBatchSizeString = null; if (configuration != null && configuration.TryGet(MaxBatchSizeConfigurationKey, out maxBatchSizeString)) { int maxBatchSize; if (!Int32.TryParse(maxBatchSizeString, out maxBatchSize)) { throw new InvalidOperationException(Strings.IntegerConfigurationValueFormatError(MaxBatchSizeConfigurationKey, maxBatchSizeString)); } _maxBatchSize = maxBatchSize; } }
/// <summary> /// 生成 SqlServer 可用的测试 Sql 语句。 /// </summary> /// <param name="node"></param> /// <returns></returns> public static FormattedSql GenerateTestSql(IQueryNode node) { var generator = new SqlServerSqlGenerator { AutoQuota = false }; generator.Generate(node as SqlNode); return generator.Sql; }
public SqlServerModificationCommandBatchFactory( [NotNull] SqlServerSqlGenerator sqlGenerator) : base(sqlGenerator) { }
public TestSqlServerModificationCommandBatchFactory(SqlServerSqlGenerator sqlGenerator) : base(sqlGenerator) { }
public TestSqlServerModificationCommandBatch(SqlServerSqlGenerator sqlGenerator, int?maxBatchSize) : base(sqlGenerator, maxBatchSize) { }