• Upgrade your Internet Experience
  • Sign in
  • Microsoft.com
  • United States (English)
    Brasil (Português)Česká republika (Čeština)Deutschland (Deutsch)España (Español)France (Français)Italia (Italiano)Россия (Русский)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語)香港特别行政區 (中文)
 
 
Microsoft Developer Network
 
 
Home
 
 
Library
 
 
Learn
 
 
Downloads
 
 
Support
 
 
Community
 
 
Forums
 
 
 
Microsoft Developer Network > Forums Home > SQL Data Services Forums > SQL Data Services (SDS) - Getting Started > Tips and tricks
Ask a questionAsk a question
Search Forums:
  • Search SQL Data Services (SDS) - Getting Started Forum Search SQL Data Services (SDS) - Getting Started Forum
  • Search All SQL Data Services Forums Search All SQL Data Services Forums
  • Search All MSDN Forums Search All MSDN Forums
 

StickyTips and tricks

  • Monday, May 19, 2008 6:28 PMTony PetrossianMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    Post your Tips here  -- Please use good subjects

    Thanks
    Tonyp
    • ReplyReply
    • QuoteQuote
     

All Replies

  • Monday, June 09, 2008 4:48 PMTony PetrossianMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    Maximum number of entities returned (page size):

    SSDS returns a maximum of 500 entities for a query result.  The result list is always ordered by the entity ID.    


    Entity order in query result:

    A query result is always ordered by entity IDs.




    Tonyp
    • ReplyReply
    • QuoteQuote
     
  • Monday, June 09, 2008 6:05 PMTony PetrossianMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    How to get more than 500 entities in a query result:

    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:

     

    string lastId = "";
    string query = @"from e in entities where e[""Someprop""]== ""Some Value"" && e.Id > ""{0}"" select e";
    while (true)
    {
      int count = 0;
      foreach (Entity entity in proxy.Query(myContainerScope, String.Format(query, lastId))
     
    {
         // Do something with entities
         …
        
    lastId = entity.Id;
         count++;
     
    }
     
    if (count < 500)
       
    break;    // last page if less than 500 results
    } 


    Tonyp
    • ReplyReply
    • QuoteQuote
     
  • Tuesday, July 08, 2008 12:55 AMShawn WildermuthMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    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.
    http://www.silverlight-tour.com
    • ReplyReply
    • QuoteQuote
     
  • Friday, October 03, 2008 6:32 PMAnilredMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    Shawn
    Is this still on your radar!!

    Anil
    • ReplyReply
    • QuoteQuote
     
  • Thursday, November 06, 2008 4:00 PMNigel Ellis [MSFT] Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
     
    Shawn Wildermuth said:

    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.


    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 "numeric order".

    Nigel.

    • ReplyReply
    • QuoteQuote
     
  • Tuesday, January 13, 2009 3:22 PMShan McArthur Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
     
    Tony Petrossian said:


    A query result is always ordered by entity IDs.


    Tonyp



    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.

    Shan McArthur
    www.shanmcarthur.net
    • ReplyReply
    • QuoteQuote
     
Need Help with Forums? (FAQ)
 
© 2009 Microsoft Corporation. All rights reserved.
Terms of Use
|
Trademarks
|
Privacy Statement