Esempio n. 1
0
        public DbAccessorMicro(string connectionString, Func <string, DbConnection> connectionFactory = null)
        {
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new ArgumentNullException(nameof(connectionString));
            }

            _db = new DbAccessorNano(connectionString, connectionFactory);
        }
Esempio n. 2
0
        static void TestNano()
        {
            // var db = new DbAccessorNano(_connectionString);
            var                  db    = new DbAccessorNano(_connectionString, (cs) => new MySql.Data.MySqlClient.MySqlConnection(cs));
            DataTable            table = db.Query("select * from Persons");
            IEnumerable <string> names = table.GetColumnValues("Name");

            Console.WriteLine("=== All fields in Name Column ===");
            Console.WriteLine(String.Join(", ", names));

            IEnumerable <Row> rows = table.GetRows(new string[] { "Id", "Name", "Age" });

            Console.WriteLine("=== Some Fields of all Rows ===");
            foreach (var row in rows)
            {
                var idField   = row["Id"];
                var nameField = row["Name"];
                var ageField  = row["Age"];
                Console.WriteLine(String.Join(", ", new string[] { idField, nameField, ageField }));
            }
        }