Print Page | Close Window

EntityQueryPagedCollectionView

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3543
Printed Date: 21-Jan-2026 at 5:21pm


Topic: EntityQueryPagedCollectionView
Posted By: gregweb
Subject: EntityQueryPagedCollectionView
Date Posted: 16-Jul-2012 at 10:07am
I have a EntityQueryPagedCollectionView. When a user wants to filter the list, I use a PredicateDescription and EQPCV.SetQueryFilter. This works fine.

However, when the user want to add a number of items to the list, I want to start with a cleared list, ie nothing in the list.

I don't see a way of doing this. There is no EQPCV.Clear() method. The only thing I can think of is creating a bogus PredicateDescription so it will return nothing. The problem with this, though, is that then when items are added, they disappear of the list after a save as they don't match the PD.

Greg



Replies:
Posted By: DenisK
Date Posted: 16-Jul-2012 at 6:49pm
Hi Greg,

The EQPCV is limited in functionality and not intended for a full CRUD operation. Not having a .Clear method is one such limitation.

Having said that, another workaround that I can think of to clear the list is set the EntityQuery.QueryStrategy to CacheOnly, call EntityManager.Clear() and call EQPCV.Refresh()

_query = _entityManager.Customers;

View = new EntityQueryPagedCollectionView(
               _query,                  // Source of data
               PageSize,               // Page size
               PageSize,               // Load size - no lookahead caching here 
               true,                   // Whether to defer the load
               false);                 // Whether to add primary key to sort columns

//other operations.........

//Clear here
ClearEQPCV();

//other operations........

//Set QueryStrategy back when done
_query.QueryStrategy = QueryStrategy.Normal;     //or _entityManager.DefaultQueryStrategy

public void ClearEQPCV() {
      _query.QueryStrategy = QueryStrategy.CacheOnly;      
      _entityManager.Clear();
      View.Refresh();
}

This essentially tricks the EQPCV query to look into an empty EM cache. Depending on your needs, you might want to create a separate edit EM for this purpose.

Hope this helps.


Posted By: gregweb
Date Posted: 17-Jul-2012 at 11:36am
Thanks Denis. I think your right in that I should create a new EM for the purpose. That will keep things much cleaner.



Greg



Print Page | Close Window