Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This was exactly my problem too.</p> <p>But my problem was solved by changing the structure of business output class method.</p> <p>And of course, in this way you need to have the data output and number of rows.</p> <p>And do not forget the issue relating to the same page layout data must be fetched from the database.</p> <p>My class was designed to do the following.</p> <pre><code>using System.Collections.Generic; using System.Linq; using Andish.CSS.Common.Enum; using AutoMapper; using system.linq.dynamic; namespace Andish.CSS.Common.Result.Implementation { public static class PagingResult { public static PageResult&lt;K&gt; ToPageResult&lt;T, K&gt;(this IQueryable&lt;T&gt; queryable, int rowCount, int pageNumber, string sortField, DynamicLinqSortFieldKind dynamicLinqSortFieldKind) { var allQueryRow = queryable.ToList&lt;T&gt;().Count(); var skipLen = (pageNumber - 1) * rowCount; string orderKind = ""; orderKind = dynamicLinqSortFieldKind == DynamicLinqSortFieldKind.Ascending ? " Asc" : " Desc"; PageResult&lt;K&gt; pageResult = new PageResult&lt;K&gt; { PageNumber = pageNumber, RowCount = rowCount, Result = Mapper.Map&lt;IList&lt;K&gt;&gt;(queryable.OrderBy(sortField + orderKind) .Skip(skipLen).Take(rowCount).ToList&lt;T&gt;()), ResultRowCount = allQueryRow, PageCount = allQueryRow % rowCount == 0 ? allQueryRow / rowCount : (allQueryRow / rowCount) + 1 }; return pageResult; } } } create this enum public enum DynamicLinqSortFieldKind { Ascending = 0, Descending = 1 } </code></pre> <p>And for use this extension Method do like this and i have one result from class ExecutiveUnit and I want map this class to enother class ExecutiveUnitModel . i use automapper nuget.</p> <pre><code>var xresult = result.ToPageResult&lt;ExecutiveUnit, ExecutiveUnitModel&gt;(RowNumbers, pageNumber, "Code", DynamicLinqSortFieldKind.Ascending); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload