Beispiel #1
0
        public static IQueryable <T> OrderBy <T>(this IQueryable <T> queryable, string propertyName, out int RecordCount, out int PageCount, ref int CurrentPage, int PageSize = 10, bool IsDesc = true, string propertyName2 = "", bool IsDesc2 = true)
        {
            //
            if (PageSize < 1)
            {
                PageSize = 1;
            }
            //
            RecordCount = queryable.Count();//记录总数
            //
            PageCount = (RecordCount + PageSize - 1) / PageSize;
            //设置当前页
            if (CurrentPage < 1)
            {
                CurrentPage = 1;
            }
            if (CurrentPage > PageCount)
            {
                //大于总页数取最大数
                CurrentPage = PageCount;
            }
            if (CurrentPage == 0)
            {
                CurrentPage = 1;
            }
            //
            dynamic keySelector = QueryableHelper <T> .GetLambdaExpression(propertyName);

            //
            return(QueryableHelper <T> .OrderBy(queryable, propertyName, IsDesc, propertyName2, IsDesc2).Skip((CurrentPage - 1) * PageSize).Take(PageSize));
        }
Beispiel #2
0
 public static IQueryable <T> OrderBy <T>(this IQueryable <T> queryable, string propertyName, bool desc)
 {
     if (string.IsNullOrEmpty(propertyName))
     {
         throw new Exception("OrderField不能为空");
     }
     else
     {
         return(QueryableHelper <T> .OrderBy(queryable, propertyName, desc));
     }
 }
        public static IQueryable <T> OrderBy <T>(this IQueryable <T> queryable, Dictionary <string, bool> propertyNames)
        {
            IOrderedQueryable <T> output = null;

            foreach (var item in propertyNames)
            {
                if (output == null)
                {
                    output = QueryableHelper <T> .OrderBy(queryable, item.Key, item.Value);
                }
                else
                {
                    output = output.ThanBy(item.Key, item.Value);
                }
            }
            return(output ?? queryable);
        }
Beispiel #4
0
        /// <summary>
        /// function get all data tblPage
        /// </summary>
        /// <returns></returns>
        public List <PageItem> GetList(out int total, string name, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.tblPage
                        where p.IsDeleted == false
                        where p.Name.ToLower().Contains(name)
                        select p;

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new PageItem()
            {
                ID = p.ID,
                Name = p.Name,
                Link = p.Link,
                ClassAtrtibute = p.ClassAtrtibute,
                Number = p.Number,
                Parent = p.Parent,
                HasChild = p.HasChild,
                IsShow = p.IsShow
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }
Beispiel #5
0
 /// <summary>
 /// 排序
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="query"></param>
 /// <param name="propertyName"></param>
 /// <param name="desc">是否倒序(true 倒序,false 顺序)</param>
 /// <returns></returns>
 public static IQueryable <T> OrderBy <T>(this IQueryable <T> query, String propertyName, Boolean desc) where T : class
 {
     return(QueryableHelper <T> .OrderBy(query, propertyName, desc));
 }
Beispiel #6
0
        /// <summary>
        /// function get all data tblTypeSupport
        /// </summary>
        /// <returns></returns>
        public List <SupportTypeItem> GetList(out int total, string name, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.tblTypeSupport
                        where p.Name.ToLower().Contains(name) && p.IsDeleted == isDelete
                        select p;

            query = query.Where(p => p.LanguageId == LanguageId);

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new SupportTypeItem()
            {
                ID = p.ID,
                Name = p.Name,
                Number = p.Number,
                IsShow = p.IsShow
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }
        /// <summary>
        /// function get all data tblTypeProduct
        /// </summary>
        /// <returns></returns>
        public List <ArticleAutoItem> GetList(out int total, string name, int?parentId, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.tblArticleAuto
                        where p.Name.ToLower().Contains(name) && p.IsDeleted == isDelete
                        select p;

            if (parentId.HasValue)
            {
                query = query.Where(p => p.Parent == parentId);
            }

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new ArticleAutoItem()
            {
                ID = p.ID,
                Name = p.Name,
                Link = p.Link,
                PictureID = p.PictureID.HasValue ? p.PictureID.Value : 0,
                Number = p.Number.HasValue ? p.Number.Value : 0,
                Parent = p.Parent,
                IsShow = p.IsShow.HasValue && p.IsShow.Value,
                IsDeleted = p.IsDeleted.HasValue && p.IsDeleted.Value,
                Xpath = p.Xpath,
                XpathTitle = p.XpathTitle,
                XpathSummary = p.XpathSummary,
                XpathDetail = p.XpathDetail,
                XpathImage = p.XpathImage,
                Xpage = p.Xpage,
                XpathPaging = p.XpathPaging,
                TypeID = p.TypeID.HasValue ? p.TypeID.Value : 0
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }
Beispiel #8
0
        /// <summary>
        /// function get all data tblFile
        /// </summary>
        /// <returns></returns>
        public List <FileItem> GetList(out int total, string name, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.tblFile
                        where p.Name.ToLower().Contains(name) && p.IsDeleted == isDelete
                        select p;

            query = query.Where(p => p.tblTypeFile.LanguageId == LanguageId);

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new FileItem()
            {
                ID = p.ID,
                Name = p.Name,
                NameAscii = p.NameAscii,
                SEOTitle = p.SEOTitle,
                SEODescription = p.SEODescription,
                SEOKeyword = p.SEOKeyword,
                Number = p.Number,
                Summary = p.Summary,
                Detail = p.Detail,
                IsShow = p.IsShow,
                TypeID = p.TypeID,
                FileName = "/UploadFile/Files/" + p.FileName
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }
Beispiel #9
0
        /// <summary>
        /// function get all data tblTypeProduct
        /// </summary>
        /// <returns></returns>
        public List <PictureItem> GetList(out int total,
                                          string name,
                                          string nameFile,
                                          int[] typeId,
                                          int currentRecord,
                                          int numberRecord,
                                          string propertyNameSort,
                                          bool descending,
                                          bool?isShow,
                                          bool isDelete = false)
        {
            var query = from p in web365db.tblPicture
                        where p.Name.ToLower().Contains(name) && p.FileName.ToLower().Contains(nameFile) && p.IsDeleted == isDelete
                        select p;

            if (typeId != null && typeId.Count() > 0)
            {
                query = query.Where(p => typeId.Contains(p.TypeID.Value));
            }

            if (isShow.HasValue)
            {
                query = query.Where(p => p.IsShow == isShow);
            }

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new PictureItem()
            {
                ID = p.ID,
                Name = p.Name,
                FileName = p.FileName,
                TypeID = p.TypeID,
                Summary = p.Summary,
                Alt = p.Alt,
                Link = p.Link,
                Size = p.Size,
                DateCreated = p.DateCreated,
                DateUpdated = p.DateUpdated,
                CreatedBy = p.CreatedBy,
                UpdatedBy = p.UpdatedBy,
                IsShow = p.IsShow,
                IsDeleted = p.IsDeleted
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }
 public static IQueryable <TEntity> OrderBy <TEntity>(this IQueryable <TEntity> table, string propertyName, bool desc)
 {
     return(QueryableHelper <TEntity> .OrderBy(table, propertyName, desc));
 }
Beispiel #11
0
        /// <summary>
        /// function get all data tblTypeProduct
        /// </summary>
        /// <returns></returns>
        public List<OrderItem> GetList(out int total,
            int? id,
            string customerName, 
            string email,
            string phone,
            int currentRecord, 
            int numberRecord, 
            string propertyNameSort,
            bool descending,
            bool? isViewed,
            bool isDelete = false)
        {
            var query = from p in web365db.tblOrder
                        where p.CustomerName.ToLower().Contains(customerName)
                        && p.Email.ToLower().Contains(email)
                        && p.Phone.ToLower().Contains(phone) 
                        && p.IsDeleted == isDelete                        
                        select p;

            if (id.HasValue)
            {
                query = query.Where(p => p.ID == id);
            }

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return query.Select(p => new OrderItem()
            {
                ID = p.ID,
                CustomerName = p.CustomerName,
                Email = p.Email,
                Phone = p.Phone,
                DateCreated = p.DateCreated,
                TotalCost = p.TotalCost,
                IsViewed = p.IsViewed
            }).Skip(currentRecord).Take(numberRecord).ToList();
        }
Beispiel #12
0
        public List <UserInfoNew3> GetDaiLyCap1(int currentPage = 0, int pageSize = 0, string fDate = "", string tDate = "", string key = "", string propertyNameSort = "", bool descending = true)
        {
            var paramTotal = new SqlParameter
            {
                ParameterName = "total",
                SqlDbType     = SqlDbType.Int,
                Direction     = ParameterDirection.Output
            };

            if (!string.IsNullOrEmpty(fDate))
            {
                fDate = Convert.ToDateTime(fDate).ToString("yyyy-MM-dd 00:00:00.000");
            }
            if (!string.IsNullOrEmpty(tDate))
            {
                tDate = Convert.ToDateTime(tDate).ToString("yyyy-MM-dd 23:59:59.999");
            }

            var query = web365DbReder.Database.SqlQuery <UserInfoNew3>("exec [dbo].[PRC_AdminGetListDailyCap1] @fDate, @tDate, @key, @currentPage, @pageSize, @total OUTPUT",
                                                                       new SqlParameter("currentPage", currentPage),
                                                                       new SqlParameter("pageSize", pageSize),
                                                                       new SqlParameter("key", key),
                                                                       new SqlParameter("fDate", fDate),
                                                                       new SqlParameter("tDate", tDate),
                                                                       paramTotal);

            var result = query.Select(p => new UserInfoNew3()
            {
                user_id             = p.user_id,
                indexRow            = p.indexRow,
                fullname            = p.fullname,
                username            = p.username,
                gameCashN           = p.gameCashN.HasValue ? p.gameCashN.Value : 0,
                CashKet             = p.CashKet.HasValue ? p.CashKet.Value : 0,
                ShopLevel           = p.ShopLevel.HasValue ? p.ShopLevel.Value : 0,
                totalSendToUser     = p.totalSendToUser.HasValue ? p.totalSendToUser.Value : 0,
                totalRecivefromUser = p.totalRecivefromUser.HasValue ? p.totalRecivefromUser.Value : 0,
                total                   = (p.totalSendToUser.HasValue ? p.totalSendToUser.Value : 0) + (p.totalRecivefromUser.HasValue ? p.totalRecivefromUser.Value : 0),
                totalTax                = p.totalTax.HasValue ? p.totalTax.Value : 0,
                totalSendToUserCap1     = p.totalSendToUserCap1.HasValue ? p.totalSendToUserCap1.Value : 0,
                totalRecivefromUserCap1 = p.totalRecivefromUserCap1.HasValue ? p.totalRecivefromUserCap1.Value : 0,
                totalCap1               = (p.totalSendToUserCap1.HasValue ? p.totalSendToUserCap1.Value : 0) + (p.totalRecivefromUserCap1.HasValue ? p.totalRecivefromUserCap1.Value : 0),
                totalTaxCap1            = p.totalTaxCap1.HasValue ? p.totalTaxCap1.Value : 0,
            }).OrderByDescending(c => c.total).ToList();


            if (!string.IsNullOrEmpty(propertyNameSort))
            {
                var rsQueryable = result.AsQueryable();
                var result2     = descending ? QueryableHelper.OrderByDescending(rsQueryable, propertyNameSort) : QueryableHelper.OrderBy(rsQueryable, propertyNameSort);

                return(result2.ToList());
            }
            else
            {
                return(result);
            }
        }
 public static IQueryable <TEntity> OrderBy <TEntity>(this IQueryable <TEntity> table, string propertyName) where TEntity : class
 {
     return(QueryableHelper <TEntity> .OrderBy(table, propertyName, false));
 }
Beispiel #14
0
        /// <summary>
        /// function get all data tblTypeArticle
        /// </summary>
        /// <returns></returns>
        public List <CommentItem> GetList(out int total, string name, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isShow = true)
        {
            var query = from p in web365db.tblComment
                        //where p.Name.ToLower().Contains(name) && p.IsShow == isShow
                        select p;

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new CommentItem()
            {
                ID = p.ID,
                Name = p.Name,
                Detail = p.Detail,
                Email = p.Email,
                CateJoinID = p.CateJoinID,
                JoinID = p.JoinID,
                IsShow = p.IsShow,
                DateCreated = p.DateCreated,
                CateName = p.tblTypeComment.Name
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }
Beispiel #15
0
        /// <summary>
        /// function get all data tblCustomer
        /// </summary>
        /// <returns></returns>
        public List <CustomerItem> GetList(out int total, string name, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.tblCustomer
                        where p.UserName.ToLower().Contains(name) && p.IsDeleted == isDelete
                        select p;

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new CustomerItem()
            {
                ID = p.ID,
                UserName = p.UserName,
                Email = p.Email,
                DateCreated = p.DateCreated,
                IsActive = p.IsActive.HasValue && p.IsActive.Value
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }
        /// <summary>
        /// function get all data tblTypeProduct
        /// </summary>
        /// <returns></returns>
        public List <ProductTypeItem> GetList(out int total, string name, int?parentId, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.tblTypeProduct
                        where p.Name.ToLower().Contains(name) && p.IsDeleted == isDelete
                        select p;

            query = query.Where(p => p.LanguageId == LanguageId);

            if (parentId.HasValue)
            {
                query = query.Where(p => p.Parent == parentId);
            }

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new ProductTypeItem()
            {
                ID = p.ID,
                Name = p.Name,
                NameAscii = p.NameAscii,
                SEOTitle = p.SEOTitle,
                SEODescription = p.SEODescription,
                SEOKeyword = p.SEOKeyword,
                PictureID = p.PictureID,
                Number = p.Number,
                Detail = p.Detail,
                Parent = p.Parent,
                IsShow = p.IsShow
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }
Beispiel #17
0
 public static IQueryable <T> OrderByDescending <T>(this IQueryable <T> queryable, string propertyName)
 {
     return(QueryableHelper <T> .OrderBy(queryable, propertyName, true));
 }
Beispiel #18
0
 public static IOrderedQueryable <T> OrderBy <T>(this IQueryable <T> queryable, string propertyName)
 {
     return(QueryableHelper <T> .OrderBy(queryable, propertyName, false));
 }
Beispiel #19
0
        /// <summary>
        /// function get all data tblTypeProduct
        /// </summary>
        /// <returns></returns>
        public List <ReceiveInfoGroupItem> GetList(out int total, string name, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.tblReceiveInfoGroup
                        where p.Name.ToLower().Contains(name) && p.IsDeleted == isDelete
                        orderby p.ID descending
                        select new ReceiveInfoGroupItem()
            {
                ID          = p.ID,
                Name        = p.Name,
                IsShow      = p.IsShow,
                DateCreated = p.DateCreated
            };

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Skip(currentRecord).Take(numberRecord).ToList());
        }
Beispiel #20
0
        /// <summary>
        /// function get all data tblProduct
        /// </summary>
        /// <returns></returns>
        public List <ProductItem> GetList(out int total,
                                          string name,
                                          string serial,
                                          int?typeId,
                                          int?manuId,
                                          int?distributorId,
                                          int?statusId,
                                          int?labelId,
                                          int currentRecord,
                                          int numberRecord,
                                          string propertyNameSort,
                                          bool descending,
                                          bool isDelete = false)
        {
            var query = from p in web365db.tblProduct
                        where p.Name.ToLower().Contains(name) && p.Serial.ToLower().Contains(serial) && p.IsDeleted == isDelete
                        select p;

            query = query.Where(p => p.tblTypeProduct.LanguageId == LanguageId);

            if (typeId.HasValue)
            {
                query = query.Where(p => p.TypeID == typeId);
            }

            if (manuId.HasValue)
            {
                query = query.Where(p => p.Manufacturer == manuId);
            }

            if (distributorId.HasValue)
            {
                query = query.Where(p => p.Distributor == distributorId);
            }

            if (statusId.HasValue)
            {
                query = query.Where(p => p.tblProduct_Status_Map.Any(s => s.ProductStatusID == statusId));
            }

            if (labelId.HasValue)
            {
                query = query.Where(p => p.tblProductLabel.Any(l => l.ID == labelId));
            }

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new ProductItem()
            {
                ID = p.ID,
                Name = p.Name,
                NameAscii = p.NameAscii,
                TypeID = p.TypeID,
                Number = p.Number,
                IsShow = p.IsShow
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }
 /// <summary>
 /// 排序
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="queryable"></param>
 /// <param name="propertyName"></param>
 /// <param name="desc">是否倒序(true 倒序,false 升序)</param>
 /// <returns></returns>
 public static IQueryable <T> OrderBy <T>(this IQueryable <T> queryable, string propertyName, bool desc)
 {
     return(QueryableHelper <T> .OrderBy(queryable, propertyName, desc));
 }
Beispiel #22
0
        /// <summary>
        /// function get all data tblDistributor
        /// </summary>
        /// <returns></returns>
        public List <ProductDistributorItem> GetList(out int total, string name, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.tblDistributor
                        where p.Name.ToLower().Contains(name) && p.IsDeleted == isDelete
                        select p;

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new ProductDistributorItem()
            {
                ID = p.ID,
                Name = p.Name,
                NameAscii = p.NameAscii,
                SEOTitle = p.SEOTitle,
                SEODescription = p.SEODescription,
                SEOKeyword = p.SEOKeyword,
                Number = p.Number,
                Summary = p.Summary,
                Detail = p.Detail,
                IsShow = p.IsShow
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }
Beispiel #23
0
        /// <summary>
        /// function get all data webpages_Roles
        /// </summary>
        /// <returns></returns>
        public List <UserRoleItem> GetList(out int total, string name, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.webpages_Roles
                        where p.IsDeleted == p.IsDeleted
                        where p.RoleName.ToLower().Contains(name)
                        select p;

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new UserRoleItem()
            {
                RoleId = p.RoleId,
                RoleName = p.RoleName,
                CreatedBy = p.CreateBy,
                UpdatedBy = p.UpdateBy,
                DateCreated = p.DateCreated,
                DateUpdated = p.DateUpdated,
                IsShow = p.IsShow
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }
Beispiel #24
0
        /// <summary>
        /// function get all data UserProfile
        /// </summary>
        /// <returns></returns>
        public List <UserProfileItem> GetList(out int total, string name, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.UserProfile
                        where p.IsDeleted == false
                        where p.UserName.ToLower().Contains(name)
                        where !p.ShopLevel.HasValue
                        select p;

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new UserProfileItem()
            {
                UserId = p.UserId,
                UserName = p.UserName,
                FirstName = p.FirstName,
                LastName = p.LastName,
                Gender = p.Gender,
                Email = p.Email,
                IsDeleted = p.IsDeleted,
                Phone = p.Phone,
                CreateBy = p.CreateBy,
                UpdateBy = p.UpdateBy,
                DateCreated = p.DateCreated,
                DateUpdated = p.DateUpdated,
                IsActive = p.IsActive
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }
Beispiel #25
0
        /// <summary>
        /// function get all data tblProductGroupAttribute
        /// </summary>
        /// <returns></returns>
        public List <ProductGroupAttributeItem> GetList(out int total, string name, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.tblProductGroupAttribute
                        where p.Name.ToLower().Contains(name) && p.IsDeleted == isDelete
                        orderby p.ID descending
                        select new ProductGroupAttributeItem()
            {
                ID        = p.ID,
                Name      = p.Name,
                NameAscii = p.NameAscii,
                Number    = p.Number,
                IsShow    = p.IsShow
            };

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Skip(currentRecord).Take(numberRecord).ToList());
        }
Beispiel #26
0
        /// <summary>
        /// function get all data tblArticle
        /// </summary>
        /// <returns></returns>
        public List <ArticleItem> GetList(out int total, string name, int?typeId, int?groupId, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.tblArticle
                        where p.IsDeleted == isDelete && !string.IsNullOrEmpty(p.LinkReference)
                        select p;

            if (typeId.HasValue)
            {
                query = query.Where(a => a.TypeID == typeId);
            }

            if (groupId.HasValue)
            {
                query = query.Where(a => a.tblGroup_Article_Map.Any(g => g.GroupID == groupId));
            }

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new ArticleItem()
            {
                ID = p.ID,
                Title = p.Title,
                TitleAscii = p.TitleAscii,
                SEOTitle = p.SEOTitle,
                SEODescription = p.SEODescription,
                SEOKeyword = p.SEOKeyword,
                Number = p.Number,
                Summary = p.Summary,
                Detail = p.Detail,
                Tags = p.Tags,
                IsShow = p.IsShow
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }
Beispiel #27
0
 /// <summary>
 ///     把IQueryable[T]集合按指定属性与排序方式进行排序
 /// </summary>
 /// <param name="source">要排序的数据集</param>
 /// <param name="propertyName">排序属性名</param>
 /// <param name="sortDirection">排序方向</param>
 /// <typeparam name="T">动态类型</typeparam>
 /// <returns>排序后的数据集</returns>
 public static IOrderedQueryable <T> OrderBy <T>(this IQueryable <T> source, string propertyName,
                                                 ListSortDirection sortDirection = ListSortDirection.Ascending)
 {
     PublicHelper.CheckArgument(propertyName, "propertyName");
     return(QueryableHelper <T> .OrderBy(source, propertyName, sortDirection));
 }
        /// <summary>
        /// function get all data tblTypeProduct
        /// </summary>
        /// <returns></returns>
        public List <PictureTypeItem> GetList(out int total, string name, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.tblTypePicture
                        where p.Name.ToLower().Contains(name) && p.IsDeleted == isDelete
                        orderby p.ID descending
                        select new PictureTypeItem()
            {
                ID             = p.ID,
                Name           = p.Name,
                NameAscii      = p.NameAscii,
                SEOTitle       = p.SEOTitle,
                SEODescription = p.SEODescription,
                SEOKeyword     = p.SEOKeyword,
                Number         = p.Number,
                Detail         = p.Detail,
                Parent         = p.Parent,
                IsShow         = p.IsShow
            };

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Skip(currentRecord).Take(numberRecord).ToList());
        }
        /// <summary>
        /// function get all data tblTypeProduct
        /// </summary>
        /// <returns></returns>
        public List <LayoutContentItem> GetList(out int total, string name, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.tblLayoutContent
                        where p.Name.ToLower().Contains(name) && p.IsDeleted == isDelete
                        select p;


            query = query.Where(p => p.LanguageId == LanguageId);

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new LayoutContentItem()
            {
                ID = p.ID,
                Name = p.Name,
                NameAscii = p.NameAscii,
                DateCreated = p.DateCreated,
                SEOTitle = p.SEOTitle,
                SEODescription = p.SEODescription,
                SEOKeyword = p.SEOKeyword,
                IsShow = p.IsShow
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }
Beispiel #30
0
        /// <summary>
        /// function get all data tblFile
        /// </summary>
        /// <returns></returns>
        public List <MenuItem> GetList(out int total, string name, int?parentId, int currentRecord, int numberRecord, string propertyNameSort, bool descending, bool isDelete = false)
        {
            var query = from p in web365db.tblMenu
                        where p.Name.ToLower().Contains(name) && p.IsDeleted == isDelete
                        select p;

            query = query.Where(p => p.LanguageId == LanguageId);

            if (parentId.HasValue)
            {
                query = query.Where(p => p.Parent == parentId);
            }

            total = query.Count();

            query = descending ? QueryableHelper.OrderByDescending(query, propertyNameSort) : QueryableHelper.OrderBy(query, propertyNameSort);

            return(query.Select(p => new MenuItem()
            {
                ID = p.ID,
                Name = p.Name,
                NameAscii = p.NameAscii,
                DateCreated = p.DateCreated,
                IsShow = p.IsShow
            }).Skip(currentRecord).Take(numberRecord).ToList());
        }