title: DomainCollectionView with DomainService + Repository pattern
body: <p>i have a view model in silverlight which loads contacts i.e.:</p>
  
  <pre><code>_ContactsSource = new EntityList&lt;ContactItem&gt;(_ContactsDomainContext.ContactItems);
  _ContactsLoader = new DomainCollectionViewLoader&lt;ContactItem&gt;(LoadCurrentCategoryContacts, LoadContactsCompleted);
  _ContactsView = new DomainCollectionView&lt;ContactItem&gt;(_ContactsLoader, _ContactsSource);
  
      public LoadOperation&lt;ContactItem&gt; LoadCurrentCategoryContacts()
      {
          var query = _ContactsDomainContext.GetContactsByCategoryIdQuery(CurrentContactCategory.Id);
          query.IncludeTotalCount = true;
  
          var op = _ContactsDomainContext.Load(query.SortAndPageBy(_ContactsView));
          return op;
      }
  
      public void LoadContactsCompleted(LoadOperation&lt;ContactItem&gt; op)
      {
          if (op.HasError)
              op.MarkErrorAsHandled();
          else if (!op.IsCanceled)
          {
              _ContactsSource.Source = op.Entities;
  
              if (op.TotalEntityCount &gt; -1)
                  _ContactsView.SetTotalItemCount(op.TotalEntityCount);
          }
      }
  </code></pre>
  
  <p>and a domain service with method which returns contacts DTO, based on their category:</p>
  
  <pre><code>   public IQueryable&lt;ContactItem&gt; GetContactsByCategoryId(int categoryId)
      {
          List&lt;ContactItem&gt; result = new List&lt;ContactItem&gt;();
          Mapper.Map(_contactRepository.GetAll(x =&gt; x.ContactCategoryId == categoryId), result); //automapper
          return result.AsQueryable();
      }
  </code></pre>
  
  <p>the question is:
  every time the domain service is used, it gets all table rows from database (i.e. _ContactsView PageSize is set to 10, the result in "return result.AsQueryable();" will have 140 elements), but only 10 elements is shown.</p>
  
  <p>What is the best way to use DomainCollectionView with wcf ria service + repository pattern, so all the filtering and paging will happen on server side, and only necessary amount of data will be returned to silverlight?</p>
  
  <p>Thank You !</p>