This project is read-only.
1

Closed

Unhandled exception in GetPagedResults<TKey>

description

I think that some form of error handling for EntityException in item.Count() may be needed here:
        public static IEnumerable<T> GetPagedResults<TKey>(
                                this System.Data.Objects.ObjectSet<T> item,
                                System.Linq.Expressions.Expression<Func<T, bool>> where,
                                System.Linq.Expressions.Expression<Func<T, TKey>> orderBy,
                                bool orderAscending,
                                nHydrate.EFCore.DataAccess.Paging paging)
        {
            var index = paging.PageIndex;
            var rpp = paging.RecordsperPage;
            if (index < 1) index = 1;
            if (rpp < 1) rpp = 1;

            paging.RecordCount = item.Count(where);
            paging.PageCount = paging.RecordCount / rpp;
            if ((paging.RecordCount % rpp) != 0) paging.PageCount++;

            var q = item.Where(where);

            if (orderAscending)
                q = q.OrderBy(orderBy);
            else
                q = q.OrderByDescending(orderBy);

            return q.Skip((index - 1) * rpp)
                            .Take(rpp)
                            .ToList();

        }
Closed Aug 8, 2013 at 8:30 PM by codetools
Missing Information

comments

codetools wrote Mar 25, 2013 at 4:21 PM

Would you please post the error your received? This might help me with this issue.

codetools wrote Aug 8, 2013 at 8:29 PM

There was no additional information provided; however there was error handling added if any of the parameters are null then null will be returned with no exception thrown.

wrote Aug 8, 2013 at 8:30 PM