Tips and tricks Post your Tips here  -- Please use good subjects<br><br>Thanks<hr size="1" align="left" width="25%">Tonyp© 2009 Microsoft Corporation. All rights reserved.Tue, 13 Jan 2009 15:22:16 Z67c0570d-acb6-4dff-9b9b-bc0ee37e9c27http://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/67c0570d-acb6-4dff-9b9b-bc0ee37e9c27#67c0570d-acb6-4dff-9b9b-bc0ee37e9c27http://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/67c0570d-acb6-4dff-9b9b-bc0ee37e9c27#67c0570d-acb6-4dff-9b9b-bc0ee37e9c27Tony Petrossianhttp://social.msdn.microsoft.com/Profile/en-US/?user=Tony%20PetrossianTips and tricks Post your Tips here  -- Please use good subjects<br><br>Thanks<hr size="1" align="left" width="25%">TonypMon, 19 May 2008 18:28:01 Z2008-05-19T18:28:01Zhttp://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/67c0570d-acb6-4dff-9b9b-bc0ee37e9c27#cf0539d8-f241-4dc2-b388-347b10534324http://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/67c0570d-acb6-4dff-9b9b-bc0ee37e9c27#cf0539d8-f241-4dc2-b388-347b10534324Tony Petrossianhttp://social.msdn.microsoft.com/Profile/en-US/?user=Tony%20PetrossianTips and tricks<font style="font-size:14px"><strong><font style="font-size:12px"></font>Maximum number of entities returned (page size):<br></strong><font style="font-size:12px"><font style="font-size:12px"><br></font>SSDS returns a maximum of 500 entities for a query result.  The result list is always ordered by the entity ID.    <br><br><br><font style="font-size:14px"><strong>Entity order in query result: </strong><font size=2><br><font style="font-size:12px"><br>A query result is always ordered by entity IDs.<br></font></font><br><br><br></font></font></font><hr size="1" align="left" width="25%">TonypMon, 09 Jun 2008 16:48:31 Z2008-06-09T16:48:31Zhttp://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/67c0570d-acb6-4dff-9b9b-bc0ee37e9c27#82994ea9-7e97-46b9-8d56-c57d1e6e19f2http://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/67c0570d-acb6-4dff-9b9b-bc0ee37e9c27#82994ea9-7e97-46b9-8d56-c57d1e6e19f2Tony Petrossianhttp://social.msdn.microsoft.com/Profile/en-US/?user=Tony%20PetrossianTips and tricks<font style="font-size:14px"><strong> How to get more than 500 entities in a query result:<br></strong></font><br>If a query has a result set smaller or equal to 500 then you get all the results of the query in one page.  If a query has more than 500 entities in the result set then you need to run the query multiple times to get all the results (500 at a time).  Since the query always returns the results in order of Entity ID you can use the last entity ID as a filter for the next query.  Here is a sample code section:<br> <p style="margin:0in 0in 12pt 27pt"><span style="color:blue;font-family:Consolas"> </p> <p style="margin:0in 0in 12pt 27pt"><span style="color:blue;font-family:Consolas">string </span><span style="color:#010001;font-family:Consolas">lastId = </span><span style="color:#a31515;font-family:Consolas">&quot;&quot;</span><span style="color:#010001;font-family:Consolas">;<br></span><span style="color:blue;font-family:Consolas">string </span><span style="color:#010001;font-family:Consolas">query = </span><span style="color:#a31515;font-family:Consolas">@&quot;from e in entities where e[&quot;&quot;Someprop&quot;&quot;]== &quot;&quot;Some Value&quot;&quot; &amp;&amp; e.Id &gt; &quot;&quot;{0}&quot;&quot; select e&quot;</span><span style="color:#010001;font-family:Consolas">;</span><br><span style="color:blue;font-family:Consolas">while </span><span style="color:#010001;font-family:Consolas">(</span><span style="color:blue;font-family:Consolas">true</span><span style="color:#010001;font-family:Consolas">)<br></span><span style="color:#010001;font-family:Consolas">{<br></span><span style="color:blue;font-family:Consolas">  int </span><span style="color:#010001;font-family:Consolas">count = 0;<br></span><span style="color:blue;font-family:Consolas">  foreach </span><span style="color:#010001;font-family:Consolas">(</span><span style="color:#2b91af;font-family:Consolas">Entity </span><span style="color:#010001;font-family:Consolas">entity </span><span style="color:blue;font-family:Consolas">in </span><span style="color:#010001;font-family:Consolas">proxy.Query(myContainerScope, </span><span style="color:#2b91af;font-family:Consolas">String.</span><span style="color:#010001;font-family:Consolas">Format(query, lastId))<br>  </span><span style="color:#010001;font-family:Consolas">{<br></span><span style="color:green;font-family:Consolas">     // Do something with entities<br></span><span style="color:green;font-family:Consolas">     …<br>     </span><span style="color:#010001;font-family:Consolas">lastId = entity.Id;<br></span><span style="color:#010001;font-family:Consolas">     count++;<br>  </span><span style="color:#010001;font-family:Consolas">}<br>  </span><span style="color:blue;font-family:Consolas">if </span><span style="color:#010001;font-family:Consolas">(count &lt; 500)<br>    </span><span style="color:blue;font-family:Consolas">break</span><span style="color:#010001;font-family:Consolas">;</span><span style="color:blue;font-family:Consolas">    </span><span style="color:green;font-family:Consolas">// last page if less than 500 results<br></span><span style="color:#010001;font-family:Consolas">}  </span></p></span><hr size="1" align="left" width="25%">TonypMon, 09 Jun 2008 18:05:15 Z2008-06-09T18:05:15Zhttp://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/67c0570d-acb6-4dff-9b9b-bc0ee37e9c27#81b048d0-389a-4730-9db0-41f16736b076http://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/67c0570d-acb6-4dff-9b9b-bc0ee37e9c27#81b048d0-389a-4730-9db0-41f16736b076Shawn Wildermuthhttp://social.msdn.microsoft.com/Profile/en-US/?user=Shawn%20WildermuthTips and tricks Since Ids are always strings we get results ordered non-numerically (e.g. 1, 100, 101).  Any way to do casting with SSDS to cast it to a int to get proper ordering?  Not that ordering by Id is important but it would be useful in other situations.<hr size="1" align="left" width="25%">http://www.silverlight-tour.comTue, 08 Jul 2008 00:55:47 Z2008-07-08T00:55:47Zhttp://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/67c0570d-acb6-4dff-9b9b-bc0ee37e9c27#a4ab8f13-6515-41e3-92a5-5665665431fbhttp://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/67c0570d-acb6-4dff-9b9b-bc0ee37e9c27#a4ab8f13-6515-41e3-92a5-5665665431fbAnilredhttp://social.msdn.microsoft.com/Profile/en-US/?user=AnilredTips and tricks Shawn<br>Is this still on your radar!!<br><br>AnilFri, 03 Oct 2008 18:32:19 Z2008-10-03T18:32:19Zhttp://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/67c0570d-acb6-4dff-9b9b-bc0ee37e9c27#84337616-fb4d-4488-bb9e-78cee2f299bahttp://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/67c0570d-acb6-4dff-9b9b-bc0ee37e9c27#84337616-fb4d-4488-bb9e-78cee2f299baNigel Ellishttp://social.msdn.microsoft.com/Profile/en-US/?user=Nigel%20EllisTips and tricks  <div class=quote><span class=quoteHeader>Shawn Wildermuth said:</span> <p>Since Ids are always strings we get results ordered non-numerically (e.g. 1, 100, 101).  Any way to do casting with SSDS to cast it to a int to get proper ordering?  Not that ordering by Id is important but it would be useful in other situations.</p></div><br>Shawn, you can accomplish this by zero padding your Id's so they follow the pattern 000001, ... 000100, etc.    This is the same trick you'll see for naming images on your digital camera and it sorts in &quot;numeric order&quot;.<br><br>Nigel.<br><br>Thu, 06 Nov 2008 16:00:23 Z2008-11-06T16:00:23Zhttp://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/67c0570d-acb6-4dff-9b9b-bc0ee37e9c27#0321b357-a157-4a1d-8f5c-6849d29439b9http://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/67c0570d-acb6-4dff-9b9b-bc0ee37e9c27#0321b357-a157-4a1d-8f5c-6849d29439b9Shan McArthurhttp://social.msdn.microsoft.com/Profile/en-US/?user=Shan%20McArthurTips and tricks  <div class=quote><span class=quoteHeader>Tony Petrossian said:</span> <p><font style="font-size:14px"><font style="font-size:12px"><font style="font-size:14px"><font size=2><font style="font-size:12px"><br>A query result is always ordered by entity IDs.<br></font></font><br></font></font></font> <hr align=left width="25%" size=1> Tonyp <p></p></div><br><br>This is not true - SDS supports orderby in the query syntax, and when that is used, results are ordered by the criteria that you state.  This means that SDS entities are not always ordered by entity IDs, and the code snippet used earlier in this tip to page will not work for ordered queries.<br><br>Shan McArthur<br><a href="http://www.shanmcarthur.net">www.shanmcarthur.net</a> Tue, 13 Jan 2009 15:22:13 Z2009-01-13T15:22:13Z