New Posts New Posts RSS Feed: EntityQueryPagedCollectionView
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

EntityQueryPagedCollectionView

 Post Reply Post Reply
Author
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Topic: EntityQueryPagedCollectionView
    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

Edited by gregweb - 16-Jul-2012 at 10:16am
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post 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.


Edited by DenisK - 16-Jul-2012 at 6:56pm
Back to Top
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down