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")); }
public string BuildTable(List <Employee> data) { var tableName = "#" + Guid.NewGuid(); _dbConnection.Execute("create table [" + tableName + "] ( Id int null, Name varchar(50) null)"); var batchRunner = new SqlBatchRunner(_dbConnection); data.ToList().ForEach(x => batchRunner.RecordingConnection.Execute(@"insert into [" + tableName + "] values(@Id, @Name)", x)); batchRunner.Run(); return(tableName); }
static void Main(string[] args) { Console.WriteLine("Running: {0}...", args[0]); if (args[0] == "events") { TestEventGeneration.Go(); } if (args[0] == "filters") { TestFilterGeneration.Go(); } if (args[0] == "sqlbatch") { SqlBatchRunner.Go(args[1], args[2]); } if (args[0] == "json-exp") { TestJsonExpressions.Go(); } Console.WriteLine("Done"); Console.ReadKey(); }