public void ExecuteQuerySingleOrDefault() { var query = new DbQuery("SELECT @parameter1 AS [Column]"); DbAssert.AreEqual(new { Column = 1 }, connection => query.QuerySingleOrDefault(connection, new { parameter1 = 1 })); }
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 })); }
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 })); }
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 })); }
public void ExecuteQueryFirstOrDefaultReturnsDefaultOnNoRows() { var query = new DbQuery("SELECT @parameter1 AS [Column] WHERE 1 = 0"); DbAssert.AreEqual(null, connection => query.QueryFirstOrDefault(connection, new { parameter1 = 1 })); }
public void ExecuteQuerySingleOrDefaultThrowsOnDuplicateColumnNames() { var query = new DbQuery("SELECT 1 AS [Column], 2 AS [Column]"); DbAssert.AreEqual(1, connection => query.QueryFirst(connection)); }
public void ExecuteQuerySingle() { var query = new DbQuery("SELECT @parameter1 AS [Column]"); DbAssert.AreEqual(1, connection => query.QuerySingle <int>(connection, new { parameter1 = 1 })); }
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 })); }