Exemplo n.º 1
0
        public static EntityList <Online> GetList(Int32 forumid = 0, String order = null, Boolean isdesc = false, Int32 start = 0, Int32 max = 200)
        {
            if (Meta.Count < CacheCount)
            {
                var list = Online.FindAllWithCache().Clone();
                if (forumid > 0)
                {
                    list = list.FindAll(__.ForumID, forumid);
                }
                // 如果隐藏游客
                if (GeneralConfigInfo.Current.WhosOnlineContract)
                {
                    list = list.FindAll(e => e.UserID > 0);
                }

                // 排序
                if (!String.IsNullOrEmpty(order))
                {
                    FieldItem fi = Meta.Table.FindByName(order);
                    if (fi != null)
                    {
                        list = list.Sort(fi.Name, isdesc);
                    }
                }

                return(list.Page(start, max));
            }
            else
            {
                // 最多返回1000行
                var exp = new WhereExpression();
                if (forumid > 0)
                {
                    exp &= _.ForumID == forumid;
                }
                if (GeneralConfigInfo.Current.WhosOnlineContract)
                {
                    exp &= _.UserID > 0;
                }

                // 排序
                ConcatExpression dexp = null;
                if (!String.IsNullOrEmpty(order))
                {
                    FieldItem fi = Meta.Table.FindByName(order);
                    if (fi != null)
                    {
                        if (isdesc)
                        {
                            dexp = fi.Desc();
                        }
                        else
                        {
                            dexp = fi.Asc();
                        }
                    }
                }

                return(FindAll(null, dexp, null, start, max));
            }
        }