Esempio n. 1
0
        /// <summary>
        /// 检查控制器是否已经存在
        /// </summary>
        /// <param name="checkController"></param>
        /// <param name="area"></param>
        /// <param name="adminmenuid"></param>
        /// <param name="parm"></param>
        /// <returns></returns>
        public bool checkController(string controller, string area, int adminmenuid, string parm)
        {
            var lambda = PredicateExtensions.True <Entity.AdminMenuInfo>();

            lambda = lambda.And(o => o.Area.Equals(area) && o.Controller.Equals(controller) && o.AdminMenuId != adminmenuid);

            if (!string.IsNullOrEmpty(parm))
            {
                lambda = lambda.And(o => o.Parm.Equals(parm));
            }
            else
            {
                lambda = lambda.And(o => o.Parm == null);
            }

            return(this.dbContext.AdminMenu.Count(lambda) > 0);
        }
        public void PredicateExtensionBuildsAndExpressionWithTrueFromExpressionEnumerable()
        {
            const string expected = "i => (((((i > 0) AndAlso (i < 5)) AndAlso (i > -1)) AndAlso (i < 6)) AndAlso True)";

            Expression <Func <int, bool> > exp1 = i => i > 0;
            Expression <Func <int, bool> > exp2 = i => i < 5;
            Expression <Func <int, bool> > exp3 = i => i > -1;
            Expression <Func <int, bool> > exp4 = i => i < 6;

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

            Expression <Func <int, bool> > andExp = new[] { exp1, exp2, exp3, exp4, trueExp }.And();
            var results = _testArray.Where(andExp.Compile());

            Assert.AreEqual(4, results.Count());
            Assert.AreEqual(expected, andExp.ToString());
        }
Esempio n. 3
0
        /// <summary>
        /// 获取字典key列表
        /// </summary>
        /// <param name="code">小写</param>
        /// <returns></returns>
        public List <Entity.DictionaryKeyInfo> getDictionaryKeyList(string code, string value2 = null, string value3 = null)
        {
            var lambda = PredicateExtensions.True <Entity.DictionaryKeyInfo>();

            lambda = lambda.And(g => g.DictionaryCode.Equals(code));

            if (!string.IsNullOrEmpty(value2))
            {
                lambda = lambda.And(g => g.Value2 == value2);
            }
            if (!string.IsNullOrEmpty(value3))
            {
                lambda = lambda.And(g => g.Value3 == value3);
            }

            return(this.dbContext.DictionaryKey.Where(lambda).OrderBy(g => g.OrderNo).ToList());
        }
Esempio n. 4
0
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="query"></param>
        private void Query(string query)
        {
            tbodySummary.InnerHtml = "";
            List <Work> macs = new List <Work>();

            using (var bll = new EquipmentBLL())
            {
                Expression <Func <TB_Equipment, bool> > expression = PredicateExtensions.True <TB_Equipment>();
                expression = expression.And(a => a.Deleted == false && a.TB_Terminal.Version == 1);
                if (!string.IsNullOrEmpty(query))
                {
                    string number = query;
                    string mode   = "";
                    int    dash   = query.LastIndexOf('-');
                    if (dash > 0)
                    {
                        number     = query.Substring(dash + 1);
                        mode       = query.Replace(number, "");
                        expression = expression.And(a => a.Number.Equals(number) && a.TB_EquipmentModel.Code.Equals(mode));
                    }
                    else
                    {
                        expression = expression.And(a => a.Number.Equals(number));
                    }
                }
                var list = bll.FindList(expression);
                if (null != list && list.Count() > 0)
                {
                    foreach (var obj in list)
                    {
                        macs.Add(new Work()
                        {
                            Id    = obj.id,
                            MacId = bll.GetFullNumber(obj),
                            Time1 = obj.RegisterTime.Value,
                            Time2 = DateTime.Now
                        });
                    }
                }
            }
            // 循环统计每一个设备的计算时间
            foreach (var mac in macs)
            {
                Query(mac);
            }
        }
        public void PredicateExtensionBuildsOrExpressionWithFalseFromExpressionEnumerable()
        {
            const string expected = "i => (((((i > 0) OrElse (i < 5)) OrElse (i > -1)) OrElse (i < 6)) OrElse False)";

            Expression <Func <int, bool> > exp1 = i => i > 0;
            Expression <Func <int, bool> > exp2 = i => i < 5;
            Expression <Func <int, bool> > exp3 = i => i > -1;
            Expression <Func <int, bool> > exp4 = i => i < 6;

            Expression <Func <int, bool> > falseExp = PredicateExtensions.False <int>();

            Expression <Func <int, bool> > orExp = new[] { exp1, exp2, exp3, exp4, falseExp }.Or();
            var results = _testArray.Where(orExp.Compile());

            Assert.AreEqual(5, results.Count());
            Assert.AreEqual(expected, orExp.ToString());
        }
Esempio n. 6
0
        /// <summary>
        /// 分页查询
        /// </summary>
        public List <dict_detail> queryPage(dict_detail record)
        {
            int _total = 0;
            Expression <Func <dict_detail, bool> > whereLambda = PredicateExtensions.True <dict_detail>();

            if (record.ID != null)

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

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

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

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

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

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

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

            if (record.DICT_ID != null)

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

            if (record.CREATE_TIME != null)

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

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

            // return LoadPageItems(5, 2, out _total, whereLambda, p => p.id, true);
        }
Esempio n. 7
0
        public List <EnterItem> FindByPage(Page <EnterItem> page, ref int count)
        {
            List <EnterItem> result = new List <EnterItem>();

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

                    case "enter_id":
                        int enter_id = int.Parse(param.Value);
                        searchPredicate = searchPredicate.And(s => s.EnterId == enter_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;
                    }
                }
                result = db.EnterItem.Where(searchPredicate).ToList();
            }
            count = result.Count;
            if (page.Params.ContainsKey("enter_id"))
            {
                result = result.OrderBy(o => o.Id).Skip(page.Start).Take(page.Limit).ToList();
            }
            else
            {
                result = result.OrderByDescending(o => o.Id).Skip(page.Start).Take(page.Limit).ToList();
            }
            return(result);
        }
Esempio n. 8
0
        /// <summary>
        /// 获取推荐城市列表
        /// </summary>
        /// <param name="cityid"></param>
        /// <returns></returns>
        public List <Entity.CityInfo> getCityList(int cityid, int show, int deep = -1)
        {
            var lambda = PredicateExtensions.True <Entity.CityInfo>();

            if (cityid > -1)
            {
                lambda = lambda.And(g => g.FatherCityId == cityid);
            }
            if (deep > -1)
            {
                lambda = lambda.And(g => g.Deep == deep);
            }
            if (show == 1)
            {
                lambda = lambda.And(g => g.Show == 1);
            }
            return(this.dbContext.City.Where(lambda).OrderBy(g => g.OrderNo).ThenBy(g => g.CityId).ToList());
        }
Esempio n. 9
0
        public IList <SysSetForm> GetListByCondition(SysSetFormCondition condition, ref Paging paging)
        {
            using (var repository = new Repository <SysSetForm>())
            {
                Expression <Func <SysSetForm, bool> > where = PredicateExtensions.True <SysSetForm>();
                if (!string.IsNullOrEmpty(condition.FuntionName))
                {
                    where = where.And(o => o.FuntionName.Contains(condition.FuntionName));
                }

                if (condition.Status.HasValue)
                {
                    where = where.And(o => o.Status == condition.Status);
                }

                return(repository.GetPaged(ref paging, where, m => m.CreateDate).ToList());
            }
        }
Esempio n. 10
0
        private IQueryable <vw_businessPartnerDocument> GetData()
        {
            List <Int32> bpIds = dc.businessPartnerSearches.Where(c => c.searchString.Equals(SearchTxtBox.Text)).Select(c => c.businessPartnerId).ToList();

            var predicate = PredicateExtensions.True <vw_businessPartnerDocument>();

            if (bpIds.Count > 0)
            {
                predicate = predicate.And(c => bpIds.Contains(c.businessPartnerId));
            }
            else
            {
                predicate = predicate.And(c => c.businessPartnerId.Equals(-1));
            }

            return(dc.vw_businessPartnerDocuments.Where(predicate).OrderByDescending(c => c.bpName).ThenBy(c => c.description));
            //return dc.vw_DeliveryLines.Where(predicate).OrderByDescending(c => c.DELDocDate).ThenByDescending(d => d.DELDocNum).ThenBy(d => d.DELLineNum);
        }
Esempio n. 11
0
        /// <summary>
        /// 查询是否预定安装
        /// </summary>
        /// <returns></returns>
        private string QueryBook()
        {
            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 && a.HasBound == false && a.Booked == false);
            var book = TerminalInstance.FindList(exp).Take(10).ToList();
            var tmp  = new List <TempTerminal>();

            foreach (var t in book)
            {
                tmp.Add(new TempTerminal(t));
            }
            return(JsonConverter.ToJson(tmp));
        }
Esempio n. 12
0
        public async Task <ListResult <User> > GetDataList(UserCondition condition)
        {
            Expression <Func <User, bool> > where = PredicateExtensions.True <User>();
            if (!string.IsNullOrEmpty(condition.UserName))
            {
                where = where.And(a => a.UserName.Contains(condition.UserName));
            }
            if (!string.IsNullOrEmpty(condition.Phone))
            {
                where = where.And(a => a.Phone.Contains(condition.Phone));
            }
            var list = await base.GetPageAsync(where, w => w.CreateTime, condition.PageIndex, condition.PageSize);

            foreach (var item in list.Item2)
            {
                item.RoleStr = await _role.GetRoleName(item.Id);
            }
            return(new ListResult <User>(condition.PageIndex, condition.PageSize, list.Item1, list.Item2));
        }
Esempio n. 13
0
        /// <summary>
        /// 获取我的评论列表
        /// </summary>
        /// <param name="page">分页数据</param>
        /// <param name="detailtype">资讯类型</param>
        /// <param name="itemid">栏目id</param>
        /// <param name="key">关键字</param>
        /// <returns></returns>
        public List <DetailReviewInfo> getDetailReviewList(PageInfo page, string channelcode, int detailid, int reviewid, int userid)
        {
            var lambda = PredicateExtensions.True <DetailReviewInfo>();

            if (!string.IsNullOrEmpty(channelcode))
            {
                lambda = lambda.And(g => g.ChannelCode == channelcode);
            }
            //会员
            if (userid > 0)
            {
                lambda = lambda.And(g => g.UserId == userid);
            }

            if (detailid > 0)
            {
                lambda = lambda.And(g => g.DetailId == detailid);
            }

            if (reviewid > 0)
            {
                lambda = lambda.And(g => g.ReplyId == reviewid);
            }
            else
            {
                lambda = lambda.And(g => g.ReplyId == 0);
            }
            if (!string.IsNullOrEmpty(page.Key))
            {
                lambda = lambda.And(g => g.Title.Contains(page.Key));
            }

            if (page.TotalCount == 0)
            {
                var list = this.dbContext.DetailReview.Where(lambda).OrderByDescending(g => g.Show).ThenByDescending(g => g.ReviewId);
                page.TotalCount = list.Count();
                return(list.Skip(page.PageSize * (page.PageNumber - 1)).Take(page.PageSize).ToList());
            }
            else
            {
                return(this.dbContext.DetailReview.Where(lambda).OrderByDescending(g => g.Show).ThenByDescending(g => g.ReviewId).Skip(page.PageSize * (page.PageNumber - 1)).Take(page.PageSize).ToList());
            }
        }
Esempio n. 14
0
 public IList <Menu> GetListByIds(List <string> ids)
 {
     if (ids != null && ids.Count > 0)
     {
         using (var repository = new Repository <Menu>())
         {
             Expression <Func <Menu, bool> > where = PredicateExtensions.True <Menu>();
             foreach (string id in ids)
             {
                 where.Or(m => m.Id.ToString() == id);
             }
             return(repository.NoTrackingDbSet.Where(where).ToList());
         }
     }
     else
     {
         return(null);
     }
 }
Esempio n. 15
0
        public bool UpdateRelatingFilters(ScrollLineDTO scroll, ref IList <CheckListFilter> filters, EnumTypeFilterMenu typeFilter)
        {
            if (scroll == null)
            {
                return(false);
            }

            //build lambda expression basic on active filter(linqKit)
            var finalPredicate = filters.Where(x => x.ActiveFilter).Aggregate(
                PredicateBuilder.New <krt_Naftan_orc_sapod>().And(x => x.keykrt == scroll.KEYKRT),
                (current, innerItemMode) => current.And(innerItemMode.FilterByField <krt_Naftan_orc_sapod>())
                );

            foreach (var item in filters)
            {
                item.CheckedValues = this._engage.GetGroup(PredicateExtensions.GroupPredicate <krt_Naftan_orc_sapod>(item.FieldName).Expand(), finalPredicate.Expand()).Select(x => x.ToString());
            }

            return(true);
        }
Esempio n. 16
0
        public IList <Media> GetListByMediaTypeId(MediaCondition condition, ref Paging paging)
        {
            using (var repository = new Repository <Media>())
            {
                Expression <Func <Media, bool> > where = PredicateExtensions.True <Media>();
                //if (condition.MediaTypeId.HasValue)
                //{
                //    where = where.And(p =>p.MediaType_Id == condition.MediaTypeId  );
                //}
                if (!string.IsNullOrEmpty(condition.FileName))
                {
                    where = where.And(p => p.FileName.Contains(condition.FileName));
                }


                //where = where.And(p => p.MediaClass == condition.MediaClass);

                return(repository.GetPaged(ref paging, where, m => m.CreateDate).ToList());
            }
        }
Esempio n. 17
0
        /// <summary>
        /// 根据父类Id获取子菜单
        /// </summary>
        /// <param name="fatherId"></param>
        /// <returns></returns>
        public List <Entity.AdminMenuInfo> getAdminMenuList(int fatherId, string type, int display)
        {
            var lambda = PredicateExtensions.True <Entity.AdminMenuInfo>();

            if (fatherId > -1)
            {
                lambda = lambda.And(o => o.FatherId == fatherId);
            }

            if (!string.IsNullOrEmpty(type))
            {
                lambda = lambda.And(o => o.RoleType == type);
            }
            if (display == 1)
            {
                lambda = lambda.And(o => o.Display == 1);
            }

            return(dbContext.AdminMenu.Where(lambda).OrderBy(g => g.RoleType).ThenBy(g => g.FatherId).ThenBy(g => g.OrderNo).ToList());
        }
Esempio n. 18
0
        /// <summary>
        /// 根据父id获取菜单
        /// </summary>
        /// <param name="fatherid"></param>
        /// <param name="RolePower"></param>
        /// <param name="userid"></param>
        /// <param name="shortCat"></param>
        /// <returns></returns>
        public List <Entity.AdminMenuInfo> getPowerList(int fatherid, int roleid, int userid, int shortcut)
        {
            if (shortcut == 1 && userid == 1)
            {
                return((from s in this.dbContext.AdminMenuShortcut
                        join m in this.dbContext.AdminMenu
                        on s.AdminMenuId equals m.AdminMenuId
                        where s.UserId == userid && s.RoleId == roleid
                        orderby m.OrderNo
                        select m).ToList());
            }

            var lambda   = PredicateExtensions.True <Entity.AdminMenuInfo>();
            var roleInfo = this.dbContext.Role.Find(roleid);

            lambda = lambda.And(o => o.Display == 1 && o.RoleType == roleInfo.RoleType);
            if (shortcut == 0)
            {
                lambda = lambda.And(o => o.FatherId == fatherid);
            }

            List <Entity.RolePowerInfo> powerList = null;
            var menus = this.dbContext.AdminMenu.Where(lambda);

            if (shortcut == 1)
            {
                powerList = (from s in this.dbContext.AdminMenuShortcut
                             join p in this.dbContext.RolePower on s.AdminMenuId equals p.AdminMenuId
                             where s.UserId == userid && p.RoleId == roleid
                             select p).ToList();
            }


            if (userid > 1 && powerList != null)
            {
                menus = from m in menus
                        join p in powerList on m.AdminMenuId equals p.AdminMenuId
                        select m;
            }
            return(menus.OrderBy(g => g.OrderNo).ToList());
        }
Esempio n. 19
0
        /// <summary>
        /// 分页查询
        /// </summary>
        public List <roles_menus> queryPage(roles_menus record)
        {
            int _total = 0;
            Expression <Func <roles_menus, bool> > whereLambda = PredicateExtensions.True <roles_menus>();

            if (record.MENU_ID != null)

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

            if (record.ROLE_ID != null)

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

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

            // return LoadPageItems(5, 2, out _total, whereLambda, p => p.id, true);
        }
Esempio n. 20
0
        private Expression <Func <InternalErrorLogEntryDbModel, bool> > ComposeFilter(ErrorLogsFilter filter)
        {
            var exp = base.ComposeBaseFilter <InternalErrorLogEntryDbModel>(filter);

            if (!string.IsNullOrWhiteSpace(filter.ServiceName))
            {
                exp = PredicateExtensions.And(exp, entry => entry.ServiceName.ToLower().Contains(filter.ServiceName.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.ExceptionTypeName))
            {
                exp = PredicateExtensions.And(exp, entry => entry.ExceptionType.ToLower().Contains(filter.ExceptionTypeName.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.Message))
            {
                exp = PredicateExtensions.And(exp, entry => entry.Message.ToLower().Contains(filter.Message.ToLower()));
            }

            return(exp);
        }
Esempio n. 21
0
        private Expression <Func <SearchQueryLogEntryDbModel, bool> > ComposeFilter(SearchQueryLogsFilter filter)
        {
            var exp = base.ComposeBaseFilter <SearchQueryLogEntryDbModel>(filter);

            if (!string.IsNullOrWhiteSpace(filter.UserId))
            {
                exp = PredicateExtensions.And(exp, entry => entry.UserId.ToLower().Contains(filter.UserId.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.SearchCriterium))
            {
                exp = PredicateExtensions.And(exp, entry => entry.SearchCriterium.ToLower().Contains(filter.SearchCriterium.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.FilterInfo))
            {
                exp = PredicateExtensions.And(exp, entry => entry.FilterInfo.ToLower().Contains(filter.FilterInfo.ToLower()));
            }

            return(exp);
        }
Esempio n. 22
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <returns></returns>
        public List <Entity.DetailGalleryInfo> getDetailGalleryList(int top, int detailid, Entity.GalleryType gallerytype, bool iscover = false)
        {
            var lambda = PredicateExtensions.True <Entity.DetailGalleryInfo>();

            lambda = lambda.And(g => g.DetailId == detailid && g.GalleryType == gallerytype);
            if (iscover)
            {
                lambda = lambda.And(g => g.Cover == 1);
            }
            else
            {
                lambda = lambda.And(g => g.Cover == 0);
            }
            if (top <= 0)
            {
                return(this.dbContext.DetailGallery.Where(lambda).OrderBy(g => g.OrderNo).ToList());
            }
            else
            {
                return(this.dbContext.DetailGallery.Where(lambda).OrderBy(g => g.OrderNo).Take(top).ToList());
            }
        }
Esempio n. 23
0
        /// <summary>
        /// 检查会员账号
        /// </summary>
        /// <param name="usercode"></param>
        /// <param name="userid"></param>
        /// <returns></returns>
        public int checkUserBindCode(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));
            }

            var info = this.dbContext.UserBind.FirstOrDefault(lambda);

            if (info != null)
            {
                return(info.UserId);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 24
0
        /// <summary>
        /// 分页查询
        /// </summary>
        public List <dept> queryPage(dept record)
        {
            int _total = 0;
            Expression <Func <dept, bool> > whereLambda = PredicateExtensions.True <dept>();

            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 (record.PID != null)

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

            if (record.ENABLED != null)

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

            if (record.CREATE_TIME != null)

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

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

            // return LoadPageItems(5, 2, out _total, whereLambda, p => p.id, true);
        }
Esempio n. 25
0
        public List <SaleItemView> ListExitItem(Page <SaleItemView> page, ref int count)
        {
            List <SaleItemView> result = new List <SaleItemView>();
            Expression <Func <SaleItemView, bool> > searchPredicate = PredicateExtensions.True <SaleItemView>();

            searchPredicate = searchPredicate.And(s => s.Status == "待出库" && (s.QuantityReal != s.Quantity || !s.MissProcess.Contains("完成")));
            if (page.Params.Count > 0)
            {
                foreach (var param in page.Params)
                {
                    switch (param.Key)
                    {
                    case "query":
                        string query = param.Value;
                        searchPredicate = searchPredicate.And(s => s.ItemName.Contains(query) || s.Code.Contains(query) || s.Barcode.Contains(query));
                        break;

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

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

                    case "store_id":
                        int store_id = int.Parse(param.Value);
                        searchPredicate = searchPredicate.And(s => s.StoreId == store_id);
                        break;
                    }
                }
            }
            result = db.SaleItemView.Where(searchPredicate).ToList();
            count  = result.Count;
            result = result.OrderByDescending(o => o.Id).Skip(page.Start).Take(page.Limit).ToList();
            return(result);
        }
Esempio n. 26
0
        /// <summary>
        /// 分页查询
        /// </summary>
        public List <user_avatar> queryPage(user_avatar record)
        {
            int _total = 0;
            Expression <Func <user_avatar, bool> > whereLambda = PredicateExtensions.True <user_avatar>();

            if (record.ID != null)

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

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

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

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

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

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

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

            if (record.CREATE_TIME != null)

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

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

            // return LoadPageItems(5, 2, out _total, whereLambda, p => p.id, true);
        }
Esempio n. 27
0
        public static Expression <Func <T, bool> > GetPredicate <T>(CriteriaComparator comparator, bool not, Func <T, dynamic> accessor, dynamic value)
        {
            var comparatorFunc = comparatorTable[comparator];

            var expr = new Func <T, bool>(x =>
            {
                var res = comparatorFunc(accessor(x), value);


                return(res);
            });

            // Inverse WHERE predicate if needed (eg. IN / NOT IN)
            if (not)
            {
                expr = PredicateExtensions.Not(expr);
            }

            Expression <Func <T, bool> > result = x => expr(x);

            return(result);
        }
Esempio n. 28
0
        public object getCommentList(string title, int pageIndex, int pageSize)
        {
            Func <int?, string> namecv = c =>
            {
                if (c != null)
                {
                    var u = users.GetById(c.Value).UserName;
                    return(u);
                }
                else
                {
                    return(string.Empty);
                }
            };
            Func <int?, string> acv = c =>
            {
                return(gyglArticle.GetById(c.Value).Title);
            };
            Expression <Func <GyglComment, bool> > express = PredicateExtensions.True <GyglComment>();

            if (!string.IsNullOrEmpty(title))
            {
                var a = gyglArticle.FindAll(n => n.Title.Contains(title)).Select(n => n.ID).ToList();
                express = express.And(n => a.Contains(n.ArticleID.Value) || n.Comment.Contains(title));
            }
            var _total = gyglComment.FindAll(express).Count();
            var _rows  = gyglComment.FindAllByPage(express, o => o.RegDate, pageSize, pageIndex).AsEnumerable().Select(s => new
            {
                ID      = s.ID,
                Name    = namecv(s.UserID),
                Reply   = namecv(s.ReplyID),
                Comment = s.Comment,
                RegDate = s.RegDate.ToString(),
                Article = acv(s.ArticleID)
            });

            return(new { total = _total, rows = _rows });
        }
Esempio n. 29
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <returns></returns>
        public List <Entity.DetailInfo> getDetailList(int top, string channelcode, int itemid, int userid, int show, string key)
        {
            var lambda = PredicateExtensions.True <Entity.DetailInfo>();

            var localtime = Config.SiteConfig.getLocalTime();

            lambda = lambda.And(g => g.Recycle != 1 && g.Display == 1 && g.DisplayTime < localtime);
            if (!string.IsNullOrEmpty(channelcode))
            {
                lambda = lambda.And(g => g.ChannelCode.Equals(channelcode));
            }
            if (itemid > 0)
            {
                var item = string.Format("|{0}|", itemid);
                lambda = lambda.And(g => g.Items.Contains(item));
            }
            if (userid > 0)
            {
                lambda = lambda.And(g => g.UserId == userid);
            }
            if (show > -1)
            {
                lambda = lambda.And(g => (g.Show & show) == show);
            }

            if (!string.IsNullOrEmpty(key))
            {
                lambda = lambda.And(g => g.SearchKey.Contains(key));
            }
            if (top > 0)
            {
                return(this.dbContext.Detail.Where(lambda).OrderByDescending(g => g.Stars).ThenByDescending(g => g.DetailId).Take(top).ToList());
            }
            else
            {
                return(this.dbContext.Detail.Where(lambda).OrderByDescending(g => g.Stars).ThenByDescending(g => g.DetailId).ToList());
            }
        }
Esempio n. 30
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="roleType"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public List <UserViewInfo> getUserList(int top, string roleType, string key, int roleid = 0, int show = 0, int locked = 0, int verify = 1)
        {
            var lambda = PredicateExtensions.True <Entity.UserViewInfo>();

            if (locked == 1)//锁定
            {
                lambda = lambda.And(g => g.LockUser == 1);
            }
            if (verify == 1)//审核
            {
                lambda = lambda.And(g => g.VerifyMember == 1);
            }
            if (roleid > 0)//角色
            {
                lambda = lambda.And(g => g.RoleId == roleid);
            }
            else if (!string.IsNullOrEmpty(roleType))
            {
                lambda = lambda.And(g => g.RoleType == roleType);
            }

            if (show > 0)
            {
                lambda = lambda.And(g => (g.Show & show) == show);
            }
            if (!string.IsNullOrEmpty(key))
            {
                lambda = lambda.And(g => g.UserName.Contains(key));
            }
            if (top > 0)
            {
                return(this.dbContext.UserView.Where(lambda).OrderByDescending(g => g.UserId).Take(top).ToList());
            }
            else
            {
                return(this.dbContext.UserView.Where(lambda).OrderByDescending(g => g.UserId).ToList());
            }
        }