示例#1
0
        public static void CrudSqlClient()
        {
            Dao.ProxyConnection(typeof(Item), "CRUD_SqlClient");
            SqlClientRegistrar.Register <Item>();
            Database     db = Db.For <Item>();
            SchemaWriter sw = db.ServiceProvider.GetNew <SchemaWriter>();

            sw.EnableDrop = true;
            sw.DropAllTables <Item>();
            sw.TryExecute(db);
            sw.Reset();
            sw.WriteSchemaScript <Item>();

            Exception ex;

            sw.TryExecute(db, out ex);
            Expect.IsNull(ex);

            // Create
            string name    = "".RandomString(8);
            Item   created = new Item();

            created.Name = name;
            created.Commit();

            // Retrieve
            ItemCollection results = Item.Where(p => p.Name == name);

            Expect.AreEqual(1, results.Count);

            // Update
            Item check = results[0];

            check.Name = "".RandomString(8);
            check.Commit();

            results = Item.Where(p => p.Name == name);
            Expect.AreEqual(0, results.Count);

            results = Item.Where(p => p.Name == check.Name);
            Expect.AreEqual(1, results.Count);

            // Delete
            check.Delete();

            results = Item.Where(p => p.Name == name);
            Expect.AreEqual(0, results.Count);

            results = Item.Where(p => p.Name == check.Name);
            Expect.AreEqual(0, results.Count);
        }
示例#2
0
 public ItemCollection Where(WhereDelegate <ItemColumns> where, OrderBy <ItemColumns> orderBy = null, Database db = null)
 {
     return(Item.Where(where, orderBy, db));
 }
示例#3
0
 public ItemCollection Where(WhereDelegate <ItemColumns> where, Database db = null)
 {
     return(Item.Where(where, db));
 }