Esempio n. 1
0
        public static IEnumerable <User> GetAllWeblog()
        {
            var db   = DbBase.CreateDBContext();
            var list = db.GetCollection <User>("users");

            return(list.FindAll());
        }
Esempio n. 2
0
        public static User GetWeblogById(int id)
        {
            var db   = DbBase.CreateDBContext();
            var list = db.GetCollection <User>("users");

            return(list.FindById(id));
        }
Esempio n. 3
0
        public static bool Update(Weblog model)
        {
            var db   = DbBase.CreateDBContext();
            var list = db.GetCollection <Weblog>("weblogs");

            return(list.Update(model));
        }
Esempio n. 4
0
        public static int GetAllCount()
        {
            var db   = DbBase.CreateDBContext();
            var list = db.GetCollection <Weblog>("weblogs");

            return(list.Count());
        }
Esempio n. 5
0
        public static void Delete(int id)
        {
            var db   = DbBase.CreateDBContext();
            var list = db.GetCollection <Weblog>("weblogs");

            list.Delete(id);
        }
Esempio n. 6
0
        public static Weblog GetWeblogById(int id)
        {
            var db   = DbBase.CreateDBContext();
            var list = db.GetCollection <Weblog>("weblogs");

            return(list.FindById(id));
        }
Esempio n. 7
0
        /// <summary>
        /// 获取全部内容
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <Weblog> GetAllWeblog()
        {
            var db   = DbBase.CreateDBContext();
            var list = db.GetCollection <Weblog>("weblogs");

            return(list.Find(Query.All("CreateTime", Query.Descending)));
        }
Esempio n. 8
0
 public static void AddWeblog(User model)
 {
     using (var db = DbBase.CreateDBContext())
     {
         var list = db.GetCollection <User>("users");
         list.Insert(model);
     }
 }
Esempio n. 9
0
        /// <summary>
        /// 获取分页内容
        /// </summary>
        /// <param name="pageindex">当前页</param>
        /// <param name="pagesize">每页几条</param>
        /// <returns></returns>
        public static IEnumerable <Weblog> GetPageWeblog(int pageindex, int pagesize)
        {
            var db   = DbBase.CreateDBContext();
            var list = db.GetCollection <Weblog>("weblogs");
            int skip = (pageindex - 1) * pagesize;

            return(list.Find(Query.All("CreateTime", Query.Descending), skip, pagesize));
        }