Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        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);
            }
        }
Ejemplo n.º 8
0
        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);
            }
        }
Ejemplo n.º 9
0
        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);
            }
        }