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: 30-Dec-2010 at 6:41am
Awesome, this works great.  I do so much appreciate the support - I might not have ever figured that one out on my own.
 
Greg
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 29-Dec-2010 at 10:44am

Hi Greg,

 
When you call AddNew(), a new instance is created using EM.CreatEntity<T> and it goes into "Edit" mode (you probably want to add data to the new entity).
 
That's intentional - you can't page while an edit is underway.
 
Once you are done editting the entity, you must call CommitNew() (or CancelNew() if you want to dispose the entity) and then you can navigate/add items to the list.
The same happens if you are editing an existing item (i.e. this.Contacts.EditItem(this.Contacts.CurrentItem)) where you will need to call CommitEdit() or CancelEdit().
 
Silvio.
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: 25-Dec-2010 at 6:35pm
I put together a small app based on the sample using an EntityQueryPagedCollectionView.  It all works fine.  Now, I would like to add an item to the list. 
 
I use EntityQueryPagedCollectionView.Add() to add the item to the list, and it does add it to the list correctly.  And I can also save it correctly.  However, after the item is added, the list then locks up.  It can no longer be paged, nor sorted, nor can more than one item be added.  Any idea what is going on with this?
 
The code looks like this:
 
public void LoadContacts()
{
             var query = _mgr.ContactEntities;

this.Contacts = new EntityQueryPagedCollectionView(
query,
this.PageSize,
this.PageSize,
true,
false
);

this.Contacts.SortDescriptions.Add(new SortDescription("Last"ListSortDirection.Descending));
this.Contacts.Refresh();

}
internal void AddContact()
{
this.Contacts.AddNew();
}
internal void SaveContact()
{
EntitySaveOperation op = this._mgr.SaveChangesAsync();
op.Completed += new EventHandler<EntitySavedEventArgs>(op_Completed);
            
}

void op_Completed(object sender, EntitySavedEventArgs e)
{
EntitySaveOperation op = sender as EntitySaveOperation;
if (op.HasError)
{
MessageBox.Show(op.Error.Message);
}
            this.Contacts.Refresh();
}
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down