Windows Mobile Support

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Monday, 28 February 2011

Cum se face paginare pe tabelele din Windows Azure

Posted on 10:23 by Unknown
Daca lucram cu tabelele din Windows Azure o sa avem nevoie sa facem paginare. Default nu avem nici un mecanism de paginare, dar acesta este usor de implementat.
In postul anterior am descris modul prin care se pot obtine mai mult de 1000 de entitati dintr-un tabel. Pe baza mecanismului prezentat anterior putem sa parcurgem datele din tabel in format paginat.
Trebuie sa ne folosim de metoda Take din LINQ, care din fericire este suportata si de LINQ folosit pentru tabelele din Windows Azure( nu trebuie sa uitam ca doar o parte din LINQ este implementat pentru Windows Azure in acest moment). Apeland metoda Take putem sa obtinem doar o parte din entitati care ne sunt returnate de catre query.
Folosindu-ne de token-urile nextPartitionToken si nextRowToken putem sa luam urmatoarele x elemente incepand de pe o anumita pozitie.
Mai jos gasiti o implementare minimala a unui mecanism de paginare.
    public class Pagination<TItem>
where TItem : class
{
private const string NoValue = "novalue";

private string _nextPartitionToken;
private string _nextRowToken;
private DataServiceQuery<TItem> _dataServiceQuery;
private List<TItem> _items;
private int _pageSize;

/// <summary>
/// TRUE when another page exist.
/// </summary>
public bool HasNextPage { get { return _nextPartitionToken != NoValue && !string.IsNullOrEmpty(_nextPartitionToken); } }

/// <summary>
/// Gets all the items of the current page.
/// </summary>
public List<TItem> Items { get { return _items; } }

/// <summary>
/// The base contructor.
/// </summary>
/// <param name="dataServiceQuery">The query that is executed on Azure tables.</param>
/// <param name="pageSize">The size of the page.</param>
public Pagination(DataServiceQuery<TItem> dataServiceQuery, int pageSize)
{
_nextPartitionToken = NoValue;
_pageSize = pageSize;
_dataServiceQuery = dataServiceQuery.Take(_pageSize);
}

/// <summary>
/// Load the next page.
/// </summary>
public void NextPage()
{
if(string.IsNullOrEmpty(_nextPartitionToken))
{
return;
}

if (_nextPartitionToken!=NoValue)
{
_dataServiceQuery.AddQueryOption("NextPartitionKey", _nextPartitionToken);
_dataServiceQuery.AddQueryOption("NextRowKey", _nextRowToken);
}

//Get the result.
var result = _dataServiceQuery.Execute();
_items = result.ToList();

//Get tokens for the next page.
QueryOperationResponse queryOperationResponse = (QueryOperationResponse)result;
queryOperationResponse.Headers.TryGetValue("x-ms-continuation-NextPartitionKey", out _nextPartitionToken);
queryOperationResponse.Headers.TryGetValue("x-ms-continuation-NextRowKey", out _nextRowToken);
}
}
Ceea ce lipseste este calcularea numarului total de pagini. Pentru a putea face acest lucru este nevoie sa executam un query care sa returneze numarul total de entitati de pe un anumit tabel.
Pentru ca utilizatorul sa aiba optiunea de a putea accesa orice pagina este nevoie ca in constructor sa executam cate un query pentru fiecare pagina in parte si sa salvam token-urile.
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in Cloud, paginare, pagination, table, Windows Azure | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Service Bus Topic - Automatic forward messages from a subscription to a topic
    Windows Azure Service Bus Topic is a service that enables us to distribute the same messages to different consumers without having to know e...
  • CDN is not the only solution to improve the page speed - Reverse Caching Proxy
    I heard more and more often think like this: “If your website is to slow, you should use a CDN.” Great, CDN is THE solution for any kind of ...
  • Content Types - Level 6: Rich Media
    Level 6: Rich Media NOTE: This is part 7 of 7 and the conclusion of this continuing series; please see earlier posts for more background inf...
  • E-Learning Vendors Attempt to Morph Mobile
    The sign should read: " Don't touch! Wet Paint !" I had a good chuckle today after receiving my latest emailed copy of the eLe...
  • Patterns in Windows Azure Service Bus - Message Splitter Pattern
    In one of my post about Service Bus Topics from Windows Azure I told you that I will write about a post that describe how we can design an a...
  • Content Types - Level 2: SMS Campaigns
    Level 2: Interactive Messaging NOTE: This is part 3 of 7 in a continuing series; please see earlier posts for more background information. L...
  • Publishing our CellCast Widget for iPad
    The rush has been on this week as our development team worked to design a new version of our CellCast Widget specifically for Apple's up...
  • Cum sa salvezi un stream direct intr-un fisier
    Cred ca este a 2-a oara când întâlnesc aceasta cerința in decurs de câteva săptămâni. Se da un stream și o locație unde trebuie salvat, se c...
  • NetCamp 2012 - Windows 8 development experience
    During this week I participate to NetCamp 2012.  This was the 6th NetCamp event and is organizing by Evensys. NetCamp is a dedicated event f...
  • Content Types - Level 3: Voice
    Level 3: Voice-based Content and Assessments NOTE: This is part 4 of 7 in a continuing series; please see earlier posts for more background ...

Categories

  • .NET
  • .NET nice to have
  • #if DEBUG
  • 15 iunie 2011
  • 15 octombrie 2011
  • 2011
  • abstracta
  • action
  • adaugare
  • ajax
  • Amsterdam
  • Android
  • aplicatii
  • App Fabric
  • Apple iSlate
  • array
  • as
  • ASP.NET
  • AsReadOnly
  • Assembly comun
  • async
  • Asynchronous programming
  • asyncron
  • Autofac
  • AutoMapper
  • az
  • Azure
  • Azure AppFabric Cache
  • Azure backup solution
  • Azure Storage Explorer
  • azure. cloud
  • backup
  • BCP utility
  • bing maps v7
  • BitArray
  • BlackBerry
  • blob
  • BlobContainerPublicAccessType
  • breakpoint
  • bucuresti
  • C#
  • cache
  • CallerMemberName
  • CellCast
  • Certificate
  • CES
  • change
  • ChannelFactory
  • clasa
  • classinitialize
  • clean code
  • click event
  • close
  • Cloud
  • Cluj
  • cluj-napoca
  • Code contracts
  • code retrat
  • codecamp
  • CollectionAssert
  • Compact Edition
  • compara
  • Comparer T .Default
  • CompareTo
  • comparison
  • comunitate
  • concurs
  • Conditional attribute
  • configurare
  • connection string
  • container
  • content type
  • control
  • Convert
  • convertAll
  • convertor
  • cross platform
  • CRUD
  • css
  • custom properties
  • custom request
  • DACPAC
  • Daniel Andres
  • data sync service
  • database
  • date time
  • datetime
  • debug
  • default
  • delegate
  • dependency injection
  • deploy
  • DeploymentItem
  • design patterns
  • Dev de Amsterdam
  • development stoage
  • dictionary
  • diferente
  • digging
  • director
  • Directory.Exist
  • disable
  • dispatcher
  • dispose
  • dropdown
  • dynamic
  • EF
  • email
  • encoding
  • entity framework
  • enum
  • enumerable
  • Environment.NewLine
  • error
  • error 404
  • error handling
  • eveniment
  • event
  • ews
  • excel
  • exception
  • exchange
  • exita
  • explicit
  • export
  • extension
  • field
  • File.Exist
  • finalize
  • fire and forget
  • Fluent interface pattern
  • format
  • func
  • GC.SuppressFinalize
  • generic
  • getdirectoryname
  • globalization
  • gmail
  • hackathon
  • Hadoop
  • handle
  • HTML
  • html 5
  • Html.ActionLink
  • http://www.blogger.com/img/blank.gif
  • HttpModule
  • IComparable
  • IE
  • ienumerable
  • IIS
  • image
  • implicit
  • import
  • int
  • internationalization
  • Internet Explorer
  • interop
  • Ioc
  • IP Filter
  • iPhone
  • iQuest
  • IStructuralEquatable
  • ITCamp
  • itspark
  • java script
  • javascript
  • July 2012
  • KeyedByTypeCollection
  • KeyNotFoundException
  • Kinect SDK
  • lambda expression
  • LightSwitch Microsoft Silverlight
  • linq
  • list
  • lista
  • lista servicii
  • liste
  • Live Connect
  • Live ID
  • load
  • localization
  • lock
  • m-learning
  • MAC
  • Mango
  • map
  • mapare
  • mapare propietati
  • messagequeue
  • meta properties
  • method
  • MethodImpl
  • Metro App
  • Microsoft
  • Microsoft Sync Framework
  • mlearning
  • mlearning devices
  • Mobile Apps
  • mobile in the cloud
  • mobile learning
  • mobile services
  • Mobile Web
  • mongoDb
  • monitorizare
  • msmq
  • multitasking
  • MVC
  • MVC 3
  • MVVM
  • namespace
  • nextpartitionkey
  • nextrowkey
  • Ninject
  • nivel acces
  • no result
  • normalize
  • nosql
  • null expcetion
  • null object pattern
  • NullReferenceException
  • OAuth API
  • office
  • offline
  • Open ID
  • openhackeu2011
  • operations
  • operator
  • optimization
  • option
  • outputcache
  • OutputCacheProvider
  • override
  • paginare
  • pagination
  • path
  • persistare
  • Portable Library tool
  • Post event – CodeCamp Cluj-Napoca
  • predicate
  • predictions
  • prezentare
  • process
  • proiect
  • property
  • propietati
  • query
  • ReadOnlyCollection
  • ReadOnlyDictionary
  • referinta
  • reflection
  • remote
  • reply command
  • request
  • request response
  • resouce
  • REST
  • REST Client
  • RESTSharp
  • ronua
  • rss
  • rulare
  • salvare in fisier
  • sc
  • schimbare timp
  • select
  • select nodes
  • send
  • serializare
  • serialization
  • Server.Transfer. Resposen.Redirect
  • service bus
  • ServiceBase
  • servicecontroller
  • sesiune
  • session
  • Session_End
  • Session_Start
  • setup
  • Sibiu
  • signalR
  • Silverlight
  • sincronizare
  • Single Responsibility Principle
  • SkyDrive
  • skype
  • smartphones
  • smtp
  • Snapguide
  • sniffer
  • socket
  • solid
  • spec#
  • sql
  • Sql Azure
  • SQL CE
  • sql server 2008 RC
  • SRP
  • startuptype
  • stateful
  • stateless
  • static
  • stergere
  • store
  • store procedure
  • stream
  • string
  • string.join
  • struct
  • StructuralEqualityComparer
  • submit
  • switch
  • Symbian
  • Synchronized
  • system
  • tabele
  • table
  • techEd 2012
  • tempdata
  • test
  • testcleanup
  • testinitialize
  • testmethod
  • thread
  • timer
  • ToLower
  • tool
  • tostring
  • Total Cost Calculator
  • trace ASP.NET
  • transcoding
  • tuplu
  • tutorial
  • TWmLearning
  • type
  • unit test
  • unittest
  • UrlParameter.Optional
  • Validate
  • validation
  • verificare
  • video
  • view
  • ViewBag
  • virtual
  • visual studio
  • VM role
  • Vunvulea Radu
  • wallpaper
  • WCF
  • WebBrower
  • WebRequest
  • where clause
  • Windows
  • windows 8
  • Windows Azure
  • Windows Azure Service Management CmdLets
  • windows live messenger
  • Windows Mobile
  • Windows Phone
  • windows service
  • windows store application
  • Windows Task
  • WinRT
  • word
  • workaround
  • XBox
  • xml
  • xmlns
  • XNA
  • xpath
  • YMesseger
  • Yonder
  • Zip

Blog Archive

  • ►  2013 (139)
    • ►  November (17)
    • ►  October (12)
    • ►  September (10)
    • ►  August (7)
    • ►  July (8)
    • ►  June (15)
    • ►  May (12)
    • ►  April (17)
    • ►  March (16)
    • ►  February (9)
    • ►  January (16)
  • ►  2012 (251)
    • ►  December (9)
    • ►  November (19)
    • ►  October (26)
    • ►  September (13)
    • ►  August (35)
    • ►  July (28)
    • ►  June (27)
    • ►  May (24)
    • ►  April (18)
    • ►  March (17)
    • ►  February (20)
    • ►  January (15)
  • ▼  2011 (127)
    • ►  December (11)
    • ►  November (20)
    • ►  October (8)
    • ►  September (8)
    • ►  August (8)
    • ►  July (10)
    • ►  June (5)
    • ►  May (8)
    • ►  April (9)
    • ►  March (14)
    • ▼  February (20)
      • Cum se face paginare pe tabelele din Windows Azure
      • Convert a collection of items to a string
      • Cum sa obtii mai mult de 1000 de entitati dintr-un...
      • Tool-uri pentru Windows Azure
      • VM role - o noua dimensiune pentru Windows Azure
      • Code Contracts
      • Intalnire RONUA: 2 martie 2011
      • SOLID - Design patterns
      • Metoda marcata cu abstract si override
      • IComparer generic - propietatea Default
      • AutoMapper - object to object mapper
      • HTML: Cum sa facem disable un element din drop down.
      • Propietati de tip array in tabelele din Windows Az...
      • Propietati de tip array in tabelele din Windows Az...
      • Cum sa "NU" rulezi mai mult de un serviciu windows...
      • System.Web.Helpers.Json.Decode + dynamic = generic...
      • Operatii CRUD pe tables in Windows Azure
      • Windows Azure - static properties & fields
      • ConvertAll - Conversia unei liste mult mai usor
      • Cum sa verificam daca un path este valid
    • ►  January (6)
  • ►  2010 (26)
    • ►  December (1)
    • ►  November (1)
    • ►  October (1)
    • ►  June (2)
    • ►  May (1)
    • ►  April (4)
    • ►  March (1)
    • ►  February (1)
    • ►  January (14)
Powered by Blogger.

About Me

Unknown
View my complete profile