Example #1
0
        public void ExecuteQuerySingleOrDefault()
        {
            var query = new DbQuery("SELECT @parameter1 AS [Column]");

            DbAssert.AreEqual(new { Column = 1 }, connection => query.QuerySingleOrDefault(connection, new { parameter1 = 1 }));
        }
Example #2
0
        public void ExecuteQuerySingleThrowsOnNoRows()
        {
            var query = new DbQuery("SELECT @parameter1 AS [Column] WHERE 1 = 0");

            DbAssert.AreEqual(new { Column = 1 }, connection => query.QuerySingle(connection, new { parameter1 = 1 }));
        }
Example #3
0
        public void ExecuteQuerySingleThrowsOnTwoRows()
        {
            var query = new DbQuery("SELECT @parameter1 AS [Column] UNION SELECT @parameter2 AS [Column] ");

            DbAssert.AreEqual(new { Column = 1 }, connection => query.QuerySingle(connection, new { parameter1 = 1, parameter2 = 2 }));
        }
Example #4
0
        public void ExecuteQueryFirstOrDefaultReturnsFirstRowOnTwoRows()
        {
            var query = new DbQuery("SELECT @parameter1 AS [Column] UNION SELECT @parameter2 AS [Column] ");

            DbAssert.AreEqual(new { Column = 1 }, connection => query.QueryFirstOrDefault(connection, new { parameter1 = 1, parameter2 = 2 }));
        }
Example #5
0
        public void ExecuteQueryFirstOrDefaultReturnsDefaultOnNoRows()
        {
            var query = new DbQuery("SELECT @parameter1 AS [Column] WHERE 1 = 0");

            DbAssert.AreEqual(null, connection => query.QueryFirstOrDefault(connection, new { parameter1 = 1 }));
        }
Example #6
0
        public void ExecuteQuerySingleOrDefaultThrowsOnDuplicateColumnNames()
        {
            var query = new DbQuery("SELECT 1 AS [Column], 2 AS [Column]");

            DbAssert.AreEqual(1, connection => query.QueryFirst(connection));
        }
Example #7
0
        public void ExecuteQuerySingle()
        {
            var query = new DbQuery("SELECT @parameter1 AS [Column]");

            DbAssert.AreEqual(1, connection => query.QuerySingle <int>(connection, new { parameter1 = 1 }));
        }
Example #8
0
        public void ExecuteQueryFirstThrowsOnNoRows()
        {
            var query = new DbQuery("SELECT @parameter1 AS [Column] WHERE 1 = 0");

            DbAssert.AreEqual(1, connection => query.QueryFirst <int>(connection, new { parameter1 = 1 }));
        }