Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Entity Framework: How to enable paging support for repository pattern

$
0
0

i found a code which seems work. just tell me how use the below code to return paged customer...may be 20 customer. also tell me how to enable sorting.

give me a small sample code which fetch customer with paging and sorting. thanks

publicinterfaceIPaged<T>:IEnumerable<T>{///<summary>/// Get the total entity count.///</summary>intCount{ get;}///<summary>/// Get a range of persited entities.///</summary>IEnumerable<T>GetRange(int index,int count);}publicclassPaged<T>:IPaged<T>{privatereadonlyIQueryable<T> source;publicPaged(IQueryable<T> source){this.source = source;}publicIEnumerator<T>GetEnumerator(){return source.GetEnumerator();}IEnumeratorIEnumerable.GetEnumerator(){returnGetEnumerator();}publicintCount{
            get {return source.Count();}}publicIEnumerable<T>GetRange(int index,int count){return source.Skip(index).Take(count);}}publicIPaged<Customer>GetCustomers();

Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>