public void TestBulkCopyWithInterface()
        {
            const int ItemCount = 10;

            // build test data
            InsightTestData[] array = new InsightTestData[ItemCount];
            for (int j = 0; j < ItemCount; j++)
            {
                array[j] = new InsightTestData()
                {
                    Int = j
                }
            }
            ;

            var profiled = new GlimpseDbConnection((DbConnection)Connection());

            using (var i = profiled.OpenWithTransactionAs <ICanBulkCopy>())
            {
                i.BulkCopy("BulkCopyData", array);
            }
        }

        #endregion
    }
		public void TestBulkLoadWithConfiguration()
		{
			const int ItemCount = 10;

			// build test data
			InsightTestData[] array = new InsightTestData[ItemCount];
			for (int j = 0; j < ItemCount; j++)
				array[j] = new InsightTestData() { Int = j };

			// bulk load the data
			long totalRows = 0;
			_sqlConnection.BulkCopy("InsightTestData", array, configure: (InsightBulkCopy bulkCopy) =>
			{
				bulkCopy.NotifyAfter = 1;
				bulkCopy.RowsCopied += (sender, args) => totalRows = args.RowsCopied;
			});

			// run the query
			var items = _connection.QuerySql<InsightTestData>("SELECT * FROM InsightTestData");
			Assert.IsNotNull(items);
			Assert.AreEqual(ItemCount, items.Count);
			Assert.AreEqual(ItemCount, totalRows);
			for (int j = 0; j < ItemCount; j++)
				Assert.AreEqual(j, items[j].Int);

			_connection.ExecuteSql("DELETE FROM InsightTestData");
		}
Exemple #3
0
        public void TestBulkLoadWithConfiguration()
        {
            var connection = Connection();

            const int ItemCount = 10;

            // build test data
            InsightTestData[] array = new InsightTestData[ItemCount];
            for (int j = 0; j < ItemCount; j++)
            {
                array[j] = new InsightTestData()
                {
                    Int = j
                }
            }
            ;

            // bulk load the data
            long totalRows = 0;

            connection.BulkCopy("BulkCopyData", array, configure: (InsightBulkCopy bulkCopy) =>
            {
                bulkCopy.NotifyAfter = 1;
                bulkCopy.RowsCopied += (sender, args) => totalRows = args.RowsCopied;
            });

            VerifyRecordsInserted(connection, ItemCount);
            Assert.AreEqual(ItemCount, totalRows);
        }
        public void TestTypeMismatchInObjectReader()
        {
            InsightTestData[] array = new InsightTestData[] { new InsightTestData() };

            // run the query
            Connection().QuerySql <InsightTestData>("InsightTestDataTestProc2", new { p = array.ToList() });
        }
        public void TestEnumerableClassListParameters()
        {
            for (int i = 0; i < 3; i++)
            {
                // build test data
                InsightTestData[] array = new InsightTestData[i];
                for (int j = 0; j < i; j++)
                {
                    array[j] = new InsightTestData()
                    {
                        Int = j
                    }
                }
                ;

                // run the query
                var items = Connection().QuerySql <InsightTestData>("SELECT * FROM @p", new { p = array.ToList() });
                Assert.IsNotNull(items);
                Assert.AreEqual(i, items.Count);
                for (int j = 0; j < i; j++)
                {
                    Assert.AreEqual(j, items[j].Int);
                }
            }

            // make sure that we cannot send up a null item in the list
            Assert.Throws <InvalidOperationException>(() => Connection().QuerySql <InsightTestData>("SELECT * FROM @p", new { p = new List <InsightTestData>()
                                                                                                                              {
                                                                                                                                  new InsightTestData(), null, new InsightTestData()
                                                                                                                              } }));
        }
Exemple #6
0
        public void TestBulkLoadWithSqlTransaction()
        {
            for (int i = 0; i < 3; i++)
            {
                using (var connection = Connection())
                {
                    connection.Open();

                    using (var tx = connection.BeginTransaction())
                    {
                        // build test data
                        InsightTestData[] array = new InsightTestData[i];
                        for (int j = 0; j < i; j++)
                        {
                            array[j] = new InsightTestData()
                            {
                                Int = j
                            }
                        }
                        ;

                        // bulk load the data
                        Cleanup();
                        connection.BulkCopy("BulkCopyData", array, transaction: tx);

                        // records should be there
                        VerifyRecordsInserted(connection, i, tx);
                    }

                    // records should be gone
                    VerifyRecordsInserted(connection, 0);
                }
            }
        }
Exemple #7
0
        public void TestBulkLoadCount()
        {
            var connection = Connection();

            const int RowCount = 3;

            for (int i = 0; i < RowCount; i++)
            {
                // build test data
                InsightTestData[] array = new InsightTestData[i];
                for (int j = 0; j < i; j++)
                {
                    array[j] = new InsightTestData()
                    {
                        Int = j
                    }
                }
                ;

                // bulk load the data
                Cleanup();
                var count = connection.BulkCopy("BulkCopyData", array);

                Assert.AreEqual(i, count);
            }
        }
        public void TestBulkCopyWithInterface()
        {
            const int ItemCount = 10;

            // build test data
            InsightTestData[] array = new InsightTestData[ItemCount];
            for (int j = 0; j < ItemCount; j++)
                array[j] = new InsightTestData() { Int = j };

            var profiled = new GlimpseDbConnection((DbConnection)Connection());

            using (var i = profiled.OpenWithTransactionAs<ICanBulkCopy>())
            {
                i.BulkCopy("BulkCopyData", array);
            }
        }
		public void TestBulkLoad()
		{
			for (int i = 0; i < 3; i++)
			{
				// build test data
				InsightTestData[] array = new InsightTestData[i];
				for (int j = 0; j < i; j++)
					array[j] = new InsightTestData() { Int = j };

				// bulk load the data
				_connection.BulkCopy("InsightTestData", array);

				VerifyRecordsInserted(_connection, i);

				_connection.ExecuteSql("DELETE FROM InsightTestData");
			}
		}
		public void TestBulkLoadAsync()
		{
			var connection = Connection();

			for (int i = 0; i < 3; i++)
			{
				// build test data
				InsightTestData[] array = new InsightTestData[i];
				for (int j = 0; j < i; j++)
					array[j] = new InsightTestData() { Int = j, Geometry = new SqlGeometry() };

				// bulk load the data
				Cleanup();
				connection.BulkCopyAsync("BulkCopyData", array).Wait();

				VerifyRecordsInserted(connection, i);
			}
		}
        public void TestBulkLoadCount()
        {
            const int RowCount = 3;
            for (int i = 0; i < RowCount; i++)
            {
                // build test data
                InsightTestData[] array = new InsightTestData[i];
                for (int j = 0; j < i; j++)
                    array[j] = new InsightTestData() { Int = j };

                // bulk load the data
                var count = _connection.BulkCopy("InsightTestData", array);

                Assert.AreEqual(i, count);

                _connection.ExecuteSql("DELETE FROM InsightTestData");
            }
        }
        public void TestBulkLoadCount()
        {
			var connection = Connection();
			
			const int RowCount = 3;
            for (int i = 0; i < RowCount; i++)
            {
                // build test data
                InsightTestData[] array = new InsightTestData[i];
                for (int j = 0; j < i; j++)
                    array[j] = new InsightTestData() { Int = j };

                // bulk load the data
				Cleanup();
				var count = connection.BulkCopy("BulkCopyData", array);

                Assert.AreEqual(i, count);
            }
        }
		public void TestEnumerableClassListParameters()
		{
			for (int i = 0; i < 3; i++)
			{
				// build test data
				InsightTestData[] array = new InsightTestData[i];
				for (int j = 0; j < i; j++)
					array[j] = new InsightTestData() { Int = j };

				// run the query
				var items = Connection().QuerySql<InsightTestData>("SELECT * FROM @p", new { p = array.ToList() });
				Assert.IsNotNull(items);
				Assert.AreEqual(i, items.Count);
				for (int j = 0; j < i; j++)
					Assert.AreEqual(j, items[j].Int);
			}

			// make sure that we cannot send up a null item in the list
			Assert.Throws<InvalidOperationException>(() => Connection().QuerySql<InsightTestData>("SELECT * FROM @p", new { p = new List<InsightTestData>() { new InsightTestData(), null, new InsightTestData() } }));
		}
		public void TestBulkLoad()
		{
			for (int i = 0; i < 3; i++)
			{
				// build test data
				InsightTestData[] array = new InsightTestData[i];
				for (int j = 0; j < i; j++)
					array[j] = new InsightTestData() { Int = j };

				// bulk load the data
				_sqlConnection.BulkCopy("InsightTestData", array);

				// run the query
				var items = _connection.QuerySql<InsightTestData>("SELECT * FROM InsightTestData");
				Assert.IsNotNull(items);
				Assert.AreEqual(i, items.Count);
				for (int j = 0; j < i; j++)
					Assert.AreEqual(j, items[j].Int);

				_connection.ExecuteSql("DELETE FROM InsightTestData");
			}
		}
		public void TestBulkLoadWithConfiguration()
		{
			var connection = Connection();

			const int ItemCount = 10;

			// build test data
			InsightTestData[] array = new InsightTestData[ItemCount];
			for (int j = 0; j < ItemCount; j++)
				array[j] = new InsightTestData() { Int = j };

			// bulk load the data
			long totalRows = 0;
			connection.BulkCopy("BulkCopyData", array, configure: (InsightBulkCopy bulkCopy) =>
			{
				bulkCopy.NotifyAfter = 1;
				bulkCopy.RowsCopied += (sender, args) => totalRows = args.RowsCopied;
			});

			VerifyRecordsInserted(connection, ItemCount);
			Assert.AreEqual(ItemCount, totalRows);
		}
        public void AsyncEnumerablePassedDirectlyToProcWithOneTVPParameterShouldMapListToParameter()
        {
            // build test data
            InsightTestData[] array = new InsightTestData[3];
            for (int j = 0; j < 3; j++)
            {
                array[j] = new InsightTestData()
                {
                    Int = j
                }
            }
            ;

            // run the query
            var items = Connection().QueryAsync <InsightTestData>("InsightTestDataTestProc", array).Result;

            Assert.IsNotNull(items);
            Assert.AreEqual(3, items.Count);
            for (int j = 0; j < 3; j++)
            {
                Assert.AreEqual(j, items[j].Int);
            }
        }
Exemple #17
0
        public void TestBulkLoadAsync()
        {
            var connection = Connection();

            for (int i = 0; i < 3; i++)
            {
                // build test data
                InsightTestData[] array = new InsightTestData[i];
                for (int j = 0; j < i; j++)
                {
                    array[j] = new InsightTestData()
                    {
                        Int = j
                    }
                }
                ;

                // bulk load the data
                Cleanup();
                connection.BulkCopyAsync("BulkCopyData", array).Wait();

                VerifyRecordsInserted(connection, i);
            }
        }
		public void TestBulkLoadWithSqlTransaction()
		{
			for (int i = 0; i < 3; i++)
			{
				using (var tx = _connection.BeginTransaction())
				{
					// build test data
					InsightTestData[] array = new InsightTestData[i];
					for (int j = 0; j < i; j++)
						array[j] = new InsightTestData() { Int = j };

					// bulk load the data
					_connection.BulkCopy("InsightTestData", array, transaction: tx);

					// records should be there
					VerifyRecordsInserted(_connection, i, tx);
				}

				// records should be gone
				VerifyRecordsInserted(_connection, 0);

				_connection.ExecuteSql("DELETE FROM InsightTestData");
			}
		}
		public void AsyncEnumerablePassedDirectlyToProcWithOneTVPParameterShouldMapListToParameter()
		{
			// build test data
			InsightTestData[] array = new InsightTestData[3];
			for (int j = 0; j < 3; j++)
				array[j] = new InsightTestData() { Int = j };

			// run the query
			var items = _connection.QueryAsync<InsightTestData>("InsightTestDataTestProc", array).Result;
			Assert.IsNotNull(items);
			Assert.AreEqual(3, items.Count);
			for (int j = 0; j < 3; j++)
				Assert.AreEqual(j, items[j].Int);
		}
		public void TestTypeMismatchInObjectReader()
		{
			InsightTestData[] array = new InsightTestData[] { new InsightTestData() };

			// run the query
			_connection.QuerySql<InsightTestData>("InsightTestDataTestProc2", new { p = array.ToList() });
		}
		public void TestBulkLoadWithSqlTransaction()
		{
			for (int i = 0; i < 3; i++)
			{
				using (var connection = Connection())
				{
					connection.Open();

					using (var tx = connection.BeginTransaction())
					{
						// build test data
						InsightTestData[] array = new InsightTestData[i];
						for (int j = 0; j < i; j++)
							array[j] = new InsightTestData() { Int = j };

						// bulk load the data
						Cleanup();
						connection.BulkCopy("BulkCopyData", array, transaction: tx);

						// records should be there
						VerifyRecordsInserted(connection, i, tx);
					}

					// records should be gone
					VerifyRecordsInserted(connection, 0);
				}
			}
		}
		public void TestBulkLoadWithAutoTransaction()
		{
			for (int i = 0; i < 3; i++)
			{
				using (var connection = _connectionStringBuilder.OpenWithTransaction())
				{
					// build test data
					InsightTestData[] array = new InsightTestData[i];
					for (int j = 0; j < i; j++)
						array[j] = new InsightTestData() { Int = j };

					// bulk load the data
					connection.BulkCopy("InsightTestData", array);

					// records should be there
					VerifyRecordsInserted(connection, i);
				}

				// records should be gone
				VerifyRecordsInserted(_connection, 0);

				_connection.ExecuteSql("DELETE FROM InsightTestData");
			}
		}