Ejemplo n.º 1
0
 static void Test_Set()
 {
     //
     var model = new Person
     {
         Username = "******",
         Password = "******",
         Age      = 1
     };
     var personDao = new PersonDao();
     var id        = personDao.Add(model);
 }
Ejemplo n.º 2
0
        private static void Test_Person()
        {
            var model = new Person
            {
                Username = "******",
                Password = "******",
                Age      = 1
            };
            var personDao  = new PersonDao();
            var isOkDelete = personDao.DeleteById(1);
            var id         = personDao.Add(model);
            var isOkUpadte = personDao.UpdateById(new Person()
            {
                Username = "******"
            }, id);
            var model01    = personDao.FindById(id);
            var whereModel = new Person {
                Id = id
            };
            var model02 = personDao.FindList(whereModel, "id=@id", 1);

            //---

            #region where--比较推荐的写法--可以提高程序的可读性

            var where = new WhereEntity <Person>()
            {
                Model = new Person()
                {
                    Id = id
                },
                Sql     = "id=@id",
                OrderBy = "id"
            };
            //
            var model03 = personDao.FindListByPage(where.Model, where.Sql, where.OrderBy, 0, 10);
            var count   = personDao.Count(where.Model, where.Sql);

            #endregion
        }