예제 #1
0
        public void EnumerableResultWithLinq([Values(1, 5, 300)] int size)
        {
            var batch = GenerateBatch(size).ToList();

            this.ConnectionFactory().SaveBatch("Test", batch);

            int i       = 0;
            var strings = this.ConnectionFactory().ReadStream <TestData>("SELECT * FROM Test")
                          .Where(obj => obj.DataInt > 15 && obj.DataInt < 100)
                          .Select(obj => obj.DataString);

            while (i < batch.Count && batch[i++].DataInt < 15)
            {
                /* nop */
            }

            foreach (var value in strings)
            {
                dynamic expected = batch[i++];
                Assert.AreEqual(expected.DataString, value);
            }

            var result = this.ConnectionFactory().ReadStream <TestData>("SELECT * FROM Test").First();

            DbTestBase.CheckTestObject(batch[0], result);
        }
예제 #2
0
        private void ReadbackAndCheck(IList <TestData> batch, bool defaultValueForString = false)
        {
            var insertedData = this.ConnectionFactory().ReadAll("SELECT * FROM Test");

            for (var i = 0; i < batch.Count; i++)
            {
                DbTestBase.CheckTestObject(batch[i], insertedData[i], defaultValueForString);
            }
        }
예제 #3
0
        public void EnumerableResult([Values(1, 5, 300)] int size)
        {
            var batch = GenerateBatch(size).ToList();

            this.ConnectionFactory().SaveBatch("Test", batch);

            int i = 0;

            foreach (var actual in this.ConnectionFactory().ReadStream <TestData>("SELECT * FROM Test"))
            {
                DbTestBase.CheckTestObject(batch[i++], actual);
            }
        }
예제 #4
0
        public void RawConnectionWithEnumerableResult([Values(1, 5, 300)] int size)
        {
            var batch = GenerateBatch(size).ToList();

            this.ConnectionFactory().SaveBatch("Test", batch);
            using (var connection = this.ConnectionFactory().Create())
            {
                connection.Open();
                int i = 0;
                foreach (var actual in connection.ReadStream("SELECT * FROM Test"))
                {
                    DbTestBase.CheckTestObject(batch[i++], actual);
                }
            }
        }
예제 #5
0
        public void DifferentPropertySetsNoFilters([Range(0, 5)] int chunkSize)
        {
            var batch = new List <object>
            {
                new { DataInt = 5, DataLong = 3000000000L, DataString = "hello world1" },
                new { DataInt = 5, DataLong = 3000000000L, DataString = "hello world2" },
                new { DataInt = 5, DataLong = 3000000000L },
                new { DataInt = 5, DataLong = 3000000000L, DataString = "hello world1" },
            };
            int insertedRowsCount = this.ConnectionFactory().SaveBatch("Test", batch, chunkSize);

            Assert.AreEqual(batch.Count, insertedRowsCount);
            var insertedData = this.ConnectionFactory().ReadAll("SELECT * FROM Test");

            for (var i = 0; i < batch.Count; i++)
            {
                DbTestBase.CheckTestObject(batch[i], insertedData[i], i == 2);
            }
        }