Tuesday, 25 October 2011

The code below can be used to correctly process the cookie string returned by a CRM data request.


public static Microsoft.Xrm.Sdk.Query.PagingInfo NextPageInfo(ref string cookie)
{
   if (String.IsNullOrWhiteSpace(cookie) == true)
      return new Microsoft.Xrm.Sdk.Query.PagingInfo();

   Microsoft.Xrm.Sdk.Query.PagingInfo rv = new Microsoft.Xrm.Sdk.Query.PagingInfo();
   rv.PagingCookie = cookie.Clone().ToString();
   // Now decode the
   System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
   xd.LoadXml(cookie);
   System.Xml.XmlNode p = xd.SelectSingleNode("cookie/@page");
   rv.PageNumber = int.Parse(p.Value) + 1;
   cookie = null;
   return rv;
}

No comments:

Post a Comment