Cleared SQL Server 2008 MCITP
Saturday, February 19, 2011
Wednesday, February 16, 2011
IncludeTotalCount Silverlight RIA Service (Server Side Paging)
If you are using Server Side Paging (may be at database or service end) and returning limited set of results you may find it difficult to get the TotalItemCount of your entities.
But the answer is simple enough:
//Enable IncludeTotalCount to true in View/ViewModel before calling the data context to load data
EntityQuery query = _assessmentContext.XQuery(1, this._pageIndex, this._pageSize);
query.IncludeTotalCount = true; // Specify that service need to collect the total item count somehow
query.IncludeTotalCount = true; // Specify that service need to collect the total item count somehow
//Load your Entity asynchronously here
// Enable your service to set an out parameter for total item count:
[Query]
public IQueryable Xs(int xID, int pageIndex, int pageSize, out int totalCount)
{
totalCount = 110;
}
}
That's it you are done you can now get the total item count in the load operation result:
private void XsLoadingCompleted(LoadOperation lo)
{
this.BusyContent = ApplicationStrings.LoadingXs;
if (!lo.HasError)
{
this.XItemCount = lo.TotalEntityCount; // total item count that you set through the out parameter //in your domain service.
{
this.BusyContent = ApplicationStrings.LoadingXs;
if (!lo.HasError)
{
this.XItemCount = lo.TotalEntityCount; // total item count that you set through the out parameter //in your domain service.
Subscribe to:
Posts (Atom)