Beispiel #1
0
        protected IQueryable <JoinedItem <T, TT> > FindInternal(bool singleCulture = false)
        {
            var objSet         = _rep.Find();
            var translationSet =
                _repTrans.Find()
                .Where(it => it.Culture == MainCulture || (!singleCulture && it.Culture == FallbackCulture));

            return(objSet.GroupJoin(translationSet, ItemKeyExp, ItemTranslationKeyExp,
                                    (i, it) =>
                                    new JoinedItem <T, TT>
            {
                Item = i,
                ItemTranslation = it.OrderBy(iit => iit.Culture == MainCulture ? 1 : 2).FirstOrDefault()
            }));
        }
        public virtual List <V> FindAllPaged(int pageNumber, int pageSize)
        {
            var result = new List <V>();

            if (pageNumber < 1)
            {
                pageNumber = 1;
            }

            var take = pageSize;
            var skip = (pageNumber - 1) * pageSize;

            // Note: silly OrderBy(y => true) is so that entity framework provider
            // won't freak out with skip and take operators.
            // They only work on a sorted result because they are LINQ operators
            var items = repository.Find().OrderBy(y => true).Skip(skip).Take(take);

            if (items != null)
            {
                result = ListPoco(items);
            }

            return(result);
        }