using System; using System.Collections; using Womb; using Tutorial; public class TutorialClass { public static void Main (string [] args) { DB db; ArrayList emp_list; db = new DB (); db.Connect ("localhost", 5432, "WombTutorial", "bob", ""); // We are connected. Loop and add a few dummy employees for (int i = 0; i < 10; i++) { Employee emp = new Employee (db); emp.surname = "Dummy employee #" + i; emp.Write (); } // Now get all employees from the table Selector selector = db.GetSelector (typeof (Employee)); emp_list = selector.Select (); // equivalent to "SELECT *" if (emp_list != null) { Console.WriteLine ("***** RESULT: we have " + emp_list.Count + " employees"); // We can loop the result list to get the atoms foreach (Employee e in emp_list) { Console.WriteLine ("[" + e.id + "] : " + e.surname); // Update the atoms : set a name e.name = "Alfred"; e.Write (); } } // Examples of selects: // Select matching a criteria // Example: select employee with id 2 using Select1 (column, value) Employee emp_2 = (Employee) selector.Select1 ("id", (int?)2); // Delete the employee, if found if (emp_2 != null) emp_2.Delete (); // Select all employees with id > 4, and sort by birthdate in descending order // using Select (constraint) ArrayList biggerThan4 = selector.Select ("WHERE id > 4 ORDER BY birthdate DESC"); db.Disconnect (); return; } }