Exemplo n.º 1
0
        public List <ItemBatchStockView> ListByBatchStock(Page <ItemBatchStockView> page, ref int count)
        {
            List <ItemBatchStockView> result = new List <ItemBatchStockView>();

            if (page.Params.Count > 0)
            {
                Expression <Func <ItemBatchStockView, bool> > searchPredicate = PredicateExtensions.True <ItemBatchStockView>();
                foreach (var param in page.Params)
                {
                    switch (param.Key)
                    {
                    case "query":
                        string query = param.Value;
                        searchPredicate = searchPredicate.And(s => s.ItemId.ToString().Contains(query) || s.ItemName.Contains(query) || s.StoreName.Contains(query) || s.Code.Contains(query) || s.Barcode.Contains(query) || s.Brand.Contains(query));
                        break;

                    case "brand":
                        string brand = param.Value;
                        searchPredicate = searchPredicate.And(s => s.Brand == brand);
                        break;

                    case "store_id":
                        int store_id = int.Parse(param.Value);
                        searchPredicate = searchPredicate.And(s => s.StoreId == store_id);
                        break;

                    case "item_id":
                        int item_id = int.Parse(param.Value);
                        searchPredicate = searchPredicate.And(s => s.ItemId == item_id);
                        break;

                    case "date_from":
                        DateTime date_from = DateTime.Parse(param.Value);
                        searchPredicate = searchPredicate.And(p => p.DateProduct.HasValue && p.DateProduct.Value >= date_from);
                        break;

                    case "date_to":
                        DateTime date_to = DateTime.Parse(param.Value);
                        searchPredicate = searchPredicate.And(p => p.DateProduct.HasValue && p.DateProduct.Value <= date_to);
                        break;

                    case "only_count":
                        string only_count = param.Value;
                        searchPredicate = searchPredicate.And(s => s.RealCount > 0);
                        break;
                    }
                }
                result = db.ItemBatchStockView.Where(searchPredicate).ToList();
            }
            else
            {
                result = db.ItemBatchStockView.ToList();
            }
            count  = result.Count;
            result = result.OrderBy(o => o.DateProduct).Skip(page.Start).Take(page.Limit).ToList();
            return(result);
        }
Exemplo n.º 2
0
 public IEnumerable <Menu> GetListByParent(MenuCondition menudition)
 {
     using (var repository = new Repository <Menu>())
     {
         Expression <Func <Menu, bool> > where = PredicateExtensions.True <Menu>();
         where = where.And(m => m.ParentId == null);
         return(repository.NoTrackingDbSet.Where(where));
     }
 }
    public static Predicate <T> AndAll <T> (IEnumerable <Predicate <T> > conditions)
    {
        Predicate <T> result = PredicateExtensions.True <T>();

        foreach (Predicate <T> cond in conditions)
        {
            result = result.And <T>(cond);
        }
        return(result);
    }
Exemplo n.º 4
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <returns></returns>
        public List <Entity.DetailChannelInfo> getDetailChannelList(int enabled = 0)
        {
            var lambda = PredicateExtensions.True <Entity.DetailChannelInfo>();

            if (enabled == 1)
            {
                lambda = lambda.And(g => g.Enabled == 1);
            }
            return(this.dbContext.DetailChannel.Where(lambda).ToList());
        }
Exemplo n.º 5
0
        public Task <List <Admins> > userList(string key = null)
        {
            Expression <Func <Admins, bool> > express = PredicateExtensions.True <Admins>();

            if (key != null)
            {
                express = express.And(n => n.UserName.Contains(key));
            }
            return(_dbContext.Admins.AsNoTracking().Where(express).OrderByDescending(r => r.RegDate).ToListAsync());
        }
Exemplo n.º 6
0
        public Task <PaginatedList <Pages> > GetPageList(int pageSize = 10, int pageIndex = 1, string keywords = "")
        {
            Expression <Func <Pages, bool> > express = PredicateExtensions.True <Pages>();

            if (keywords != "")
            {
                express = express.And(n => n.Title.Contains(keywords) || n.PContent.Contains(keywords));
            }
            return(PaginatedList <Pages> .CreateAsync(_dbContext.Pages.AsNoTracking().Where(express).OrderByDescending(o => o.RegDate), pageIndex, pageSize));
        }
Exemplo n.º 7
0
        public List <Options> List(Page <Options> page, ref int count)
        {
            List <Options> result = new List <Options>();

            if (page.Params.Count > 0)
            {
                Expression <Func <Dictionary, bool> > searchPredicate = PredicateExtensions.True <Dictionary>();
                foreach (var param in page.Params)
                {
                    switch (param.Key)
                    {
                    case "module":
                        string str = param.Value;
                        searchPredicate = searchPredicate.And(d => d.Module.ToLower().Contains(str.ToLower()));
                        break;

                    case "field":
                        string str1 = param.Value;
                        searchPredicate = searchPredicate.And(d => d.Field.ToLower().Contains(str1.ToLower()));
                        break;

                    case "table_name":
                        string table_name = param.Value;
                        searchPredicate = searchPredicate.And(d => d.TableName == table_name);
                        break;

                    case "record_id":
                        int record_id = int.Parse(param.Value);
                        searchPredicate = searchPredicate.And(d => d.RecordId == record_id);
                        break;

                    default:
                        break;
                    }
                }
                if (page.Params.ContainsKey("table_name"))
                {
                    result = db.Dictionary.Where(searchPredicate).Select(d => new Options()
                    {
                        Id = d.OrderNo.Value, Key = d.Options, Value = d.Field
                    }).ToList();
                }
                else
                {
                    result = db.Dictionary.Where(searchPredicate).Select(d => new Options()
                    {
                        Id = d.OrderNo.Value, Key = d.Options, Value = d.Options
                    }).ToList();
                }
            }

            count = result.Count;
            return(result);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取全部角色
        /// </summary>
        /// <returns></returns>
        public List <Entity.RoleInfo> getRoleEnabledList(string roletype = null)
        {
            var lambda = PredicateExtensions.True <Entity.RoleInfo>();

            lambda = lambda.And(g => g.Lock == 0);
            if (!string.IsNullOrEmpty(roletype))
            {
                lambda = lambda.And(g => g.RoleType.Equals(roletype));
            }
            return(this.dbContext.Role.Where(lambda).OrderBy(g => g.OrderNo).ToList());
        }
Exemplo n.º 9
0
        /// <summary>
        /// 根据角色类型获取最小阅读权限角色实体
        /// </summary>
        /// <param name="roleid"></param>
        /// <returns></returns>
        public Entity.RoleInfo getRoleByReadPower(string roletype, int readpower)
        {
            var lambda = PredicateExtensions.True <Entity.RoleInfo>();

            lambda = lambda.And(g => g.RoleType == roletype && g.Lock == 0);
            if (readpower > 0)
            {
                lambda = lambda.And(g => g.ReadPower >= readpower);
            }
            return(this.dbContext.Role.Where(lambda).OrderBy(g => g.ReadPower).FirstOrDefault());
        }
Exemplo n.º 10
0
        /// <summary>
        /// 获取会员绑定账号
        /// </summary>
        /// <param name="modulecode"></param>
        /// <param name="usercode"></param>
        /// <returns></returns>
        public Entity.UserBindInfo getUserBindInfo(string modulecode, string usercode)
        {
            var lambda = PredicateExtensions.True <Entity.UserBindInfo>();

            lambda = lambda.And(g => g.UserCode.Equals(usercode));
            if (!string.IsNullOrEmpty(modulecode))
            {
                lambda = lambda.And(g => g.ModuleCode.Equals(modulecode));
            }

            return(this.dbContext.UserBind.FirstOrDefault(lambda));
        }
Exemplo n.º 11
0
        /// <summary>
        /// 获取列表
        /// </summary>
        public List <ScoreEventInfo> getScoreEventList(int eventType)
        {
            var lambda = PredicateExtensions.True <Entity.ScoreEventInfo>();

            lambda = lambda.And(g => g.Enabled == 1);
            if (eventType > -1)
            {
                lambda = lambda.And(g => g.EventType == eventType);
            }

            return(this.dbContext.ScoreEvent.Where(lambda).OrderByDescending(g => g.EventId).ToList());
        }
Exemplo n.º 12
0
 /// <summary>
 /// 查询代列表
 /// </summary>
 /// <param name="json"></param>
 /// <returns></returns>
 public JObject GetDlInfoList(vw_MallDLInfo mallDlInfo, Pagination page)
 {
     try
     {
         using (var db = new RepositoryBase())
         {
             JObject ret = new JObject();
             PaginationResult <List <vw_MallDLInfo> > ResultPage  = new PaginationResult <List <vw_MallDLInfo> >();
             Expression <Func <vw_MallDLInfo, bool> > expressions = PredicateExtensions.True <vw_MallDLInfo>();
             if (mallDlInfo != null)
             {
                 if (mallDlInfo.GameId != null && mallDlInfo.GameId > 0)
                 {
                     expressions = expressions.And(c => c.GameId == mallDlInfo.GameId);
                 }
                 if (mallDlInfo.GroupId != null && mallDlInfo.GroupId > 0)
                 {
                     expressions = expressions.And(c => c.GroupId == mallDlInfo.GroupId);
                 }
                 if (mallDlInfo.ServerId != null && mallDlInfo.ServerId > 0)
                 {
                     expressions = expressions.And(c => c.ServerId == mallDlInfo.ServerId);
                 }
                 if (!string.IsNullOrEmpty(mallDlInfo.DlType))
                 {
                     expressions = expressions.And(c => c.DlType == mallDlInfo.DlType);
                 }
                 if (!string.IsNullOrEmpty(mallDlInfo.WorkerType))
                 {
                     expressions = expressions.And(c => c.WorkerType == mallDlInfo.WorkerType);
                 }
                 if (!string.IsNullOrEmpty(mallDlInfo.DlNo))
                 {
                     expressions = expressions.And(c => c.DlNo == mallDlInfo.DlNo);
                 }
                 ResultPage.datas      = db.FindList(page, out page, expressions);
                 ResultPage.pagination = page;
             }
             else
             {
                 ResultPage.datas = db.FindList <vw_MallDLInfo>(page == null ? Pagination.GetDefaultPagination("GoodNo") : page).ToList();
             }
             ret.Add(ResultInfo.Result, true);
             ret.Add(ResultInfo.Content, JToken.FromObject(ResultPage));
             return(ret);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + "处发生了错误!");
     }
 }
        public void PredicateExtensionBuildsOrExpressionWithTrue()
        {
            const string expected = "i => ((i > 5) OrElse True)";

            Expression <Func <int, bool> > exp1    = i => i > 5;
            Expression <Func <int, bool> > trueExp = PredicateExtensions.True <int>();

            Expression <Func <int, bool> > orExp = exp1.Or(trueExp);
            var results = _testArray.Where(orExp.Compile());

            Assert.AreEqual(5, results.Count());
            Assert.AreEqual(expected, orExp.ToString());
        }
        public void PredicateExtensionBuildsAndExpressionWithTrue()
        {
            const string expected = "i => ((i > 0) AndAlso True)";

            Expression <Func <int, bool> > exp1    = i => i > 0;
            Expression <Func <int, bool> > trueExp = PredicateExtensions.True <int>();

            Expression <Func <int, bool> > andExp = exp1.And(trueExp);
            var results = _testArray.Where(andExp.Compile());

            Assert.AreEqual(5, results.Count());
            Assert.AreEqual(expected, andExp.ToString());
        }
Exemplo n.º 15
0
        /// <summary>
        /// 普通查询终端
        /// </summary>
        /// <returns></returns>
        private string QueryNormal()
        {
            var exp = PredicateExtensions.True <TB_Terminal>();

            if (!string.IsNullOrEmpty(data))
            {
                exp = exp.And(a => a.Number.Contains(data) || a.Sim.Contains(data));
            }
            exp = exp.And(a => a.Delete == false);
            var normal = TerminalInstance.FindList(exp).Take(10).ToList();

            return(JsonConverter.ToJson(normal));
        }
Exemplo n.º 16
0
        public OperateResult GetPagedMeberCardList(GetPagedMeberCardListViewModel viewModel)
        {
            //总记录数
            int rowCount = 0;

            //当用户什么都没有输入的时候默认查询所有的
            var query = PredicateExtensions.True <MemCards>();

            //根据用户输入的参数信息实现多条件查询
            if (!string.IsNullOrWhiteSpace(viewModel.CardId))
            {
                query = query.And(e => e.MC_CardID == viewModel.CardId);
            }
            if (!string.IsNullOrWhiteSpace(viewModel.Name))
            {
                query = query.And(e => e.MC_Name.Contains(viewModel.Name));
            }
            if (!string.IsNullOrWhiteSpace(viewModel.Mobile))
            {
                query = query.And(e => e.MC_Mobile == viewModel.Mobile);
            }
            if (viewModel.CardLevelId > 0)
            {
                query = query.And(e => e.CL_ID == viewModel.CardLevelId);
            }
            if (viewModel.State > 0)
            {
                query = query.And(e => e.MC_State == viewModel.State);
            }
            var pageData = GetList(viewModel.page, viewModel.rows, ref rowCount, query, e => e.MC_ID, false)
                           .Select(e => new MeberCardListViewModel()
            {
                CardId        = e.MC_CardID,
                CardLevelName = e.CardLevels.CL_LevelName,
                CreateTime    = (DateTime)e.MC_CreateTime,
                Id            = e.MC_ID,
                Mobile        = e.MC_Mobile,
                Name          = e.MC_Name,
                Point         = (int)e.MC_Point,
                Sex           = ((SexTypeEnum)e.MC_Sex).ToString(),
                State         = ((CardStateTypeEnum)e.MC_State).ToString(),
                TotalMoney    = (float)e.MC_TotalMoney
            }).AsQueryable().ToList();

            var dataGridViewModel = new DataGridViewModel()
            {
                total = rowCount, rows = pageData
            };

            return(new OperateResult(true, "", dataGridViewModel));
        }
Exemplo n.º 17
0
        public List <Company> FindCompanyByPage(Page <Company> page, ref int count)
        {
            List <Company> result = new List <Company>();

            if (page.Params.Count > 0)
            {
                if (page.Params.ContainsKey("type"))
                {
                    string type = page.Params["type"];
                    if (type == "client")
                    {
                        Expression <Func <Client, bool> > searchPredicate = PredicateExtensions.True <Client>();
                        foreach (var param in page.Params)
                        {
                            switch (param.Key)
                            {
                            case "code":
                                string code = param.Value;
                                searchPredicate = searchPredicate.And(s => s.Code.Contains(code));
                                break;
                            }
                        }
                        result = db.Client.Where(searchPredicate).Select(c => new Company()
                        {
                            Id = c.Id, Name = c.ClientName
                        }).ToList();
                    }
                    if (type == "supply")
                    {
                        Expression <Func <Supply, bool> > searchPredicate = PredicateExtensions.True <Supply>();
                        foreach (var param in page.Params)
                        {
                            switch (param.Key)
                            {
                            case "code":
                                string code = param.Value;
                                searchPredicate = searchPredicate.And(s => s.Code.Contains(code));
                                break;
                            }
                        }
                        result = db.Supply.Where(searchPredicate).Select(c => new Company()
                        {
                            Id = c.Id, Name = c.SupplyName
                        }).ToList();
                    }
                }
            }
            count  = result.Count;
            result = result.OrderByDescending(o => o.Id).Skip(page.Start).Take(page.Limit).ToList();
            return(result);
        }
Exemplo n.º 18
0
        /// <summary>
        /// 分页查询
        /// </summary>
        public List <role> queryPage(role record)
        {
            int _total = 0;
            Expression <Func <role, bool> > whereLambda = PredicateExtensions.True <role>();

            if (record.ID != null)

            {
                whereLambda.And(p => p.ID.Equals(record.ID));
            }

            if (!String.IsNullOrEmpty(record.NAME))

            {
                whereLambda.And(p => p.NAME.Equals(record.NAME));
            }

            if (!String.IsNullOrEmpty(record.REMARK))

            {
                whereLambda.And(p => p.REMARK.Equals(record.REMARK));
            }

            if (!String.IsNullOrEmpty(record.DATA_SCOPE))

            {
                whereLambda.And(p => p.DATA_SCOPE.Equals(record.DATA_SCOPE));
            }

            if (record.LEVEL != null)

            {
                whereLambda.And(p => p.LEVEL.Equals(record.LEVEL));
            }

            if (record.CREATE_TIME != null)

            {
                whereLambda.And(p => p.CREATE_TIME.Equals(record.CREATE_TIME));
            }

            if (!String.IsNullOrEmpty(record.PERMISSION))

            {
                whereLambda.And(p => p.PERMISSION.Equals(record.PERMISSION));
            }

            return(LoadPageItems(5, 2, out _total, whereLambda, p => p.ID, true));

            // return LoadPageItems(5, 2, out _total, whereLambda, p => p.id, true);
        }
Exemplo n.º 19
0
        //
        // GET: /Pager/

        public ActionResult Index(int?page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;

            IMembershipServiceInModule membershipService = DependencyResolver.Current.GetService <IMembershipServiceInModule>();
            Pagination pagination = new Pagination(currentPageIndex);

            Expression <Func <UserEntity, bool> > pre = PredicateExtensions.True <UserEntity>();


            var allUsers = membershipService.Fetch((x => ((x.NormalizedUserName == "" && x.Id == 1) || x.Password == "")), (x => x.Asc(d => d.Password, d => d.Password)), pagination);

            return(View(allUsers.ToPagedList(currentPageIndex, 5, 10)));
        }
Exemplo n.º 20
0
        public Task <PaginatedList <News> > GetNewsList(int pageSize = 10, int pageIndex = 1, string keywords = "", string category = "")
        {
            Expression <Func <News, bool> > express = PredicateExtensions.True <News>();

            if (keywords != "")
            {
                express = express.And(n => n.Title.Contains(keywords) || n.NewsDetail.Contains(keywords));
            }
            if (category != "")
            {
                express = express.And(n => n.ColumnID == int.Parse(category));
            }
            return(PaginatedList <News> .CreateAsync(_dbContext.News.AsNoTracking().Where(express).OrderByDescending(o => o.RegDate), pageIndex, pageSize));
        }
Exemplo n.º 21
0
        /// <summary>
        /// 查询绑定状态
        /// </summary>
        /// <returns></returns>
        private string QueryBound()
        {
            var exp = PredicateExtensions.True <TB_Terminal>();

            exp = exp.And(a => a.HasBound == ("bound" == cmd ? true : false));
            if (!string.IsNullOrEmpty(data))
            {
                exp = exp.And(a => a.Number.Contains(data) || a.Sim.Contains(data));
            }
            exp = exp.And(a => a.Delete == false);
            var bound = TerminalInstance.FindList(exp).Take(10).ToList();

            return(JsonConverter.ToJson(bound));
        }
Exemplo n.º 22
0
        public IList <Activity_Activitys> SearchActivity(ActivityCondition condition, ref Paging paging)
        {
            CupcakeEntities db = new CupcakeEntities();

            Expression <Func <Activity_Activitys, bool> > where = PredicateExtensions.True <Activity_Activitys>();
            if (condition.ActityType != null)
            {
                where = where.And(n => n.ActityType == condition.ActityType);
            }
            where        = where.And(n => n.IsDelete == false);
            paging.Total = db.Activity_Activitys.Where(n => n.ActityType == condition.ActityType).Count();
            return(db.Activity_Activitys.Where(where).OrderBy(n => n.CreateDate)
                   .Skip(paging.PageSize * paging.PageIndex)
                   .Take(paging.PageSize).ToList());
        }
Exemplo n.º 23
0
        private IQueryable <vw_name_in_user> GetData()
        {
            var predicate = PredicateExtensions.True <vw_name_in_user>();

            if (!String.IsNullOrEmpty(name))
            {
                predicate = predicate.And(c => c.name.Equals(name));
            }
            if (!String.IsNullOrEmpty(userName))
            {
                predicate = predicate.And(c => c.UserName.Equals(userName));
            }

            return(dc.vw_name_in_users.Where(predicate).OrderByDescending(c => c.name));
        }
Exemplo n.º 24
0
        /// <summary>
        /// 根据角色类型获取最小阅读权限角色实体
        /// </summary>
        /// <param name="roleid"></param>
        /// <returns></returns>
        public Entity.RoleInfo getRoleByScore(string roletype, int score)
        {
            var lambda = PredicateExtensions.True <Entity.RoleInfo>();

            lambda = lambda.And(g => g.RoleType == roletype && g.Lock == 0);
            if (score > 0)
            {
                lambda = lambda.And(g => g.MinScore <= score);
                return(this.dbContext.Role.Where(lambda).OrderByDescending(g => g.MinScore).FirstOrDefault());
            }
            else
            {
                return(this.dbContext.Role.Where(lambda).OrderBy(g => g.MinScore).FirstOrDefault());
            }
        }
Exemplo n.º 25
0
        private IQueryable <businessPartner> GetData()
        {
            var predicate = PredicateExtensions.True <businessPartner>();

            if (!String.IsNullOrEmpty(bpCode))
            {
                predicate = predicate.And(c => c.bpCode.Equals(bpCode));
            }

            predicate = predicate.And(c => c.bpMother.Equals(null));
            predicate = predicate.And(c => c.bpType.Equals("C"));
            predicate = predicate.And(c => !c.isMother);

            return(dc.businessPartners.Where(predicate).OrderBy(c => Convert.ToInt32(c.bpCode)));
        }
Exemplo n.º 26
0
 public IList <Menu> GetListByCondition(MenuCondition menudition, ref Paging paging)
 {
     using (var repository = new Repository <Menu>())
     {
         Expression <Func <Menu, bool> > where = PredicateExtensions.True <Menu>();
         if (!string.IsNullOrEmpty(menudition.MenuName))
         {
             where = where.And(u => u.Name == menudition.MenuName);
         }
         if (menudition.ParentMenuID != null)
         {
             where = where.And(u => u.ParentId == new Guid(menudition.ParentMenuID));
         }
         return(repository.GetPaged(ref paging, where, m => m.Sort, false).ToList());
     }
 }
Exemplo n.º 27
0
        /// <summary>
        /// 获取项目Id
        /// </summary>
        /// <param name="fatherid"></param>
        /// <returns></returns>
        public List <Entity.ItemInfo> getItemList(string code, int fahterid, int show)
        {
            var lambda = PredicateExtensions.True <Entity.ItemInfo>();

            lambda = lambda.And(g => g.ChannelCode == code);
            if (fahterid > -1)
            {
                lambda = lambda.And(g => g.FatherId == fahterid);
            }
            if (show > -1)
            {
                lambda = lambda.And(g => (g.Show & show) == show);
            }

            return(this.dbContext.Item.Where(lambda).OrderBy(g => g.OrderNo).ToList());
        }
Exemplo n.º 28
0
        /// <summary>
        /// 检查会员
        /// </summary>
        /// <param name="username"></param>
        /// <param name="userid"></param>
        /// <returns></returns>
        public int checkUserName(string username, int userid = -1)
        {
            var config = Config.SiteConfig.load();
            var lambda = PredicateExtensions.True <Entity.UserViewInfo>();

            lambda = lambda.And(g => g.UserName.Equals(username));
            if (userid > 0)
            {
                lambda = lambda.And(g => g.UserId != userid);
            }
            if (config.DuplicationUserName)
            {
                lambda = lambda.And(g => g.RoleType == "admin");
            }
            return(this.dbContext.UserView.Where(lambda).Count());
        }
Exemplo n.º 29
0
        private IQueryable <businessPartner> GetData()
        {
            var predicate = PredicateExtensions.True <businessPartner>();


            if (!String.IsNullOrEmpty(bpName))
            {
                predicate = predicate.And(c => c.bpName.Equals(bpName));
            }
            if (!String.IsNullOrEmpty(bpCode))
            {
                predicate = predicate.And(c => c.bpCode.Equals(bpCode));
            }

            return(dc.businessPartners.Where(predicate).OrderByDescending(c => c.bpName));
        }
Exemplo n.º 30
0
        public List <Purchase> FindByPage(Page <Purchase> page, ref int count)
        {
            List <Purchase> result = new List <Purchase>();

            if (page.Params.Count > 0)
            {
                Expression <Func <Purchase, bool> > searchPredicate = PredicateExtensions.True <Purchase>();
                string type = page.Params.ContainsKey("type") ? page.Params["type"] : "";
                foreach (var param in page.Params)
                {
                    switch (param.Key)
                    {
                    case "query":
                        string query = param.Value;
                        if (type == "明细")
                        {
                            List <int?> ids = db.PurchaseItem.Where(i => i.ItemId.ToString().Contains(query) || i.ItemNo.Contains(query) || i.ItemName.Contains(query) || i.MissProcess.Contains(query) || i.Remark.Contains(query)).Select(i => i.PurchaseId).ToList();
                            searchPredicate = searchPredicate.And(s => ids.Contains(s.Id));
                        }
                        else
                        {
                            searchPredicate = searchPredicate.And(s => s.Id.ToString().Contains(query) || s.SupplyName.Contains(query) || s.Status.Contains(query) || s.AddName.Contains(query) || s.CheckName.Contains(query) || s.ApproveName.Contains(query) || s.Remark.Contains(query));
                        }

                        break;

                    case "date_from":
                        DateTime date_from = DateTime.Parse(param.Value);
                        searchPredicate = searchPredicate.And(p => p.DateAdded.HasValue && p.DateAdded.Value >= date_from);
                        break;

                    case "date_to":
                        DateTime date_to = DateTime.Parse(param.Value);
                        searchPredicate = searchPredicate.And(p => p.DateAdded.HasValue && p.DateAdded.Value <= date_to);
                        break;
                    }
                }
                result = db.Purchase.Where(searchPredicate).ToList();
            }
            else
            {
                result = db.Purchase.ToList();
            }
            count  = result.Count;
            result = result.OrderByDescending(o => o.Id).Skip(page.Start).Take(page.Limit).ToList();
            return(result);
        }