private void InsertUsingSqlBatchRunner(IEnumerable<int> ids)
        {
            var batchRunner = new SqlBatchRunner(TestDb.Connection);
            foreach (var id in ids)
                InsertOneRecord(batchRunner.RecordingConnection, id);

            batchRunner.Run();
        }
        public void GetSqlStatementTest_ArrayHandling()
        {
            var ids = Enumerable.Range(1, 3).Select(x => new { id = x });

            var batchRunner = new SqlBatchRunner(TestDb.Connection);
            batchRunner.RecordingConnection.Execute("select @id", ids);

            var sql = batchRunner.GetRecordedSql();
            Assert.That(sql, Is.EqualTo("select 1\r\nselect 2\r\nselect 3\r\n"));
        }
        public void GetSqlStatementTest_IEnumerableHandling()
        {
            var ids = Enumerable.Range(1, 10);

            var batchRunner = new SqlBatchRunner(TestDb.Connection);
            batchRunner.RecordingConnection.Execute("select 1 where 1 in (@ids)", new { ids });

            var sql = batchRunner.GetRecordedSql();
            Assert.That(sql, Is.EqualTo("select 1 where 1 in (('1','2','3','4','5','6','7','8','9','10'))\r\n"));
        }
Esempio n. 4
0
        public TempIdTable(IDbConnection conn, IEnumerable <int> ids, string tableName)
        {
            TableName = tableName;
            _conn     = conn;

            ExecuteNonQuery(conn, "create table " + tableName + " (id int not null)");

            var batchRunner = new SqlBatchRunner(conn);

            foreach (var id in ids)
            {
                ExecuteNonQuery(batchRunner.RecordingConnection, "insert into " + tableName + "(id) values(" + id + ")");
            }

            batchRunner.Run();
        }
Esempio n. 5
0
        public TempIdTable(IDbConnection conn, IEnumerable<int> ids, string tableName)
        {
            TableName = tableName;
            _conn = conn;

            ExecuteNonQuery(conn, "create table " + tableName + " (id int not null)");

            var batchRunner = new SqlBatchRunner(conn);

            foreach (var id in ids)
            {
                ExecuteNonQuery(batchRunner.RecordingConnection, "insert into " + tableName + "(id) values(" + id + ")");
            }

            batchRunner.Run();
        }