c# - creating a web service with paging -


i creating web service in asp.net 2.0 c# , have web method looks this:

 [webmethod()]     public list<comment> getyoursaycomments(int pagenumber, int pagesize, int commenttopicid)     {         commentmanager cm = new commentmanager();         return cm.getyoursaycomments(pagenumber, pagesize, commenttopicid, true);      } 

this working greate services returned entities, method returns paged results. best way return total row count client?

you have create custom type include count:

public class envelopewithcount<t> {     public t value { get; set; }     public int rowcount { get; set; } } 

and web service return new type:

[webmethod] public envelopewithcount<list<comment>> getyoursaycomments(int pagenumber,                                                            int pagesize,                                                            int commenttopicid) {     commentmanager cm = new commentmanager();     envelope<list<comment>> retrunval = new envelope<list<comment>>();     returnval.value = cm.getyoursaycomments(pagenumber,                                             pagesize,                                             commenttopicid,                                             true);     // count of rows need     returnval.rowcount = cm.getyoursaycomments(true).count();      return returnval; } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -