Example #1
0
        /// <summary>
        /// 复杂查询
        /// </summary>
        /// <param name="model">查询对象</param>
        /// <param name="Orders">排序字典key:排序的字段,value:asc升序/desc降序</param>
        /// <param name="PageSize">每页行数,默认15</param>
        /// <param name="PageIndex">当前页码,默认100</param>
        /// <returns></returns>
        public DataGrid <T_LogModel> Search(T_LogModel model, Dictionary <string, string> Orders = null, int PageSize = 15, int PageIndex = 100)
        {
            Expression <Func <T_Log, bool> > where = null;                   //最终查询条件
            var lambdaList = new List <Expression <Func <T_Log, bool> > >(); //lambda查询条件集合
            int total      = 0;                                              //总行数

            if (model.BeginTime.HasValue)
            {
                lambdaList.Add(c => c.CreateTime >= (DateTime)model.BeginTime);
            }
            if (model.EndTime.HasValue)
            {
                lambdaList.Add(c => c.CreateTime <= (DateTime)model.EndTime);
            }
            //将集合表达式树转换成Expression表达式树
            MyVisitor <T_Log, T_Log> visitor = new MyVisitor <T_Log, T_Log>();

            where = visitor.Modify(lambdaList);
            var list   = dal.Search(out total, where, Orders, PageSize, PageIndex).DTOList().ToList();
            var result = new DataGrid <T_LogModel>()
            {
                rows  = list,
                total = total
            };

            return(result);
        }
Example #2
0
 public static T_Log ToModel(this T_LogModel node)
 {
     return(new T_Log()
     {
         Id = node.Id,
         StaffName = node.StaffName,
         Ip = node.Ip,
         LoginId = node.LoginId,
         Types = node.Types,
         CreateTime = DateTime.Now,
     });
 }
Example #3
0
        public static T_LogModel DTO(this T_Log node)
        {
            if (node == null)
            {
                return(null);
            }
            var model = new T_LogModel()
            {
                Id         = node.Id,
                StaffName  = node.StaffName,
                Ip         = node.Ip,
                LoginId    = node.LoginId,
                Types      = node.Types,
                CreateTime = node.CreateTime,
            };

            return(model);
        }
Example #4
0
 public int DeleteData(T_LogModel model)
 {
     return(this.Delete(model.Id));
 }
Example #5
0
 public int EditData(T_LogModel model)
 {
     return(this.Edit(model.ToModel()));
 }
Example #6
0
 public int AddData(T_LogModel model)
 {
     return(this.Add(model.ToModel()));
 }