public async Task ExecuteRowAsync_Lambda_Test() { using (var cmd = new DatabaseCommand(_connection)) { cmd.Log = Console.WriteLine; var emp = await cmd.Query("SELECT EName FROM EMP WHERE EMPNO = 7369") .ExecuteRowAsync(new { EName = String.Empty }); Assert.AreEqual("SMITH", emp.EName); } }
public void CompactFluent_Test() { using (var cmd = new DatabaseCommand(_connection)) { cmd.Log = Console.WriteLine; int count = cmd.Query("SELECT COUNT(*) FROM EMP") .ExecuteScalar <int>(); Assert.AreEqual(14, count); } }
public async Task ExecuteRowAsync_Simple_Test() { using (var cmd = new DatabaseCommand(_connection)) { cmd.Log = Console.WriteLine; var emp = await cmd.Query("SELECT * FROM EMP WHERE EMPNO = 7369") .ExecuteRowAsync <EMP>(); Assert.AreEqual("SMITH", emp.EName); } }
public async Task ExecuteScalarAsync_Simple_Test() { using (var cmd = new DatabaseCommand(_connection)) { cmd.Log = Console.WriteLine; int count = await cmd.Query("SELECT COUNT(*) FROM EMP") .ExecuteScalarAsync <int>(); Assert.AreEqual(14, count); } }
public void Parameters_NameValue_Test() { using (var cmd = new DatabaseCommand(_connection)) { cmd.Log = Console.WriteLine; int count = cmd.Query("SELECT COUNT(*) FROM EMP WHERE EMPNO > @ID") .AddParameter("ID", 10) .ExecuteScalar <int>(); Assert.AreEqual(14, count); } }
public void ExecuteTable_Lambda_Test() { using (var cmd = new DatabaseCommand(_connection)) { cmd.Log = Console.WriteLine; var employees = cmd.Query("SELECT EMPNO, ENAME FROM EMP") .ExecuteTable(new { EmpNo = 0, EName = String.Empty }); var emp = employees.First(i => i.EmpNo == 7369); Assert.AreEqual("SMITH", emp.EName); } }
public void ExecuteTable_Simple_Test() { using (var cmd = new DatabaseCommand(_connection)) { cmd.Log = Console.WriteLine; var employees = cmd.Query("SELECT * FROM EMP ") .ExecuteTable <EMP>(); var emp = employees.First(i => i.EmpNo == 7369); Assert.AreEqual("SMITH", emp.EName); } }
public void CompactFluent_WithParameters_Test() { // Query(string, T) is a obsolete method using (var cmd = new DatabaseCommand(_connection)) { cmd.Log = Console.WriteLine; int count = cmd.Query("SELECT COUNT(*) FROM EMP WHERE EMPNO > @ID", new { ID = 10 }) .ExecuteScalar <int>(); Assert.AreEqual(14, count); } }
public void ForSql_Test() { using (var cmd = new DatabaseCommand(_connection)) { // Query() Onsolete method cmd.Log = Console.WriteLine; int count = cmd.Query() .ForSql("SELECT COUNT(*) FROM EMP") .ExecuteScalar <int>(); Assert.AreEqual(14, count); } }