C# Class IdeaBlade.Windows.EntityQueryPagedCollectionView

A collection providing paging, sorting, grouping and filtering of query results.
The EntityQueryPagedCollectionView can be used from code behind, and view models in MVVM architectures, to provide paged results to bound controls. It is also used internally by the ObjectDataSource when declarative specification in XAML is wanted.

The EntityQuery provided in the constructor will be executed asynchronously as needed to fulfill each paging request. Note that unless a CacheOnly query strategy is defined, the first time a page is loaded it will use a DataSourceOnly fetch strategy. Subsequent executions will use the QueryStrategy defined on the query. Note that the query must be an EntityQuery, you can't use this collection with a StoredProcQuery or PassthruEsqlQuery. For those queries, use the .NET PagedCollectionView instead.

The EntityManager of the query is used to perform query execution. If none is specified an exception is thrown. If the EntityManager is not logged in, an asynchronous login with null credentials is performed.

To use with a DataPager control, set or bind its Source property to an instance of the EntityQueryPagedCollectionView.

Inheritance: IPagedCollectionView, ICollectionView, IEditableCollectionView, INotifyPropertyChanged
Mostra file Open project: IdeaBlade/DevForce.Utilities Class Usage Examples

Private Properties

Property Type Description
AddCachingActions IEnumerable
BeginTrackPageLoading void
BuildFilteredQuery EntityQuery
BuildOrderedQuery EntityQuery
DoGrouping void
DoInitialLoad void
EndTrackPageLoading void
EntityQueryPagedCollectionView IdeaBlade.Core
GetLookAheadCount int
GetMemberExpression System.Linq.Expressions.Expression
GetScalarQuery IEntityScalarQuery
GetSortDescriptionList IList
GetTryRefreshPosition int
IndexToUserState string
InitFields void
InitialLoadCore IEnumerable
IsPageLoadOutstanding bool
LoadPage void
LoadPageComplete void
MakePagedQuery IEntityQuery
OnPageLoadError PageLoadErrorEventArgs
ReloadCurrentPage void
RemoveItemFromList void
SetCurrentInfo bool
SetTotalItemCount void
ShouldLoadLookAheadPage bool
UserStateToIndex int

Public Methods

Method Description
AddNew ( ) : object

Creates an item and adds it to the collection for editing.

Calls BeginEdit if the item implements IEditableObject. EntityManager.CreateEntity is used to create the item.

CancelEdit ( ) : void

Cancels editing of the CurrentEditItem.

Calls CancelEdit if the item implements IEditableObject.

CancelNew ( ) : void

Cancels editing of the CurrentAddItem.

Calls CancelEdit if the item implements IEditableObject.

ClearQueryFilter ( ) : void

Can be used to clear the filter.

After clearing the filter, call Refresh to re-query and load the view.

Calling either of the SetQueryFilter(IPredicateDescription) overloads with a null value will also clear the filter.

CommitEdit ( ) : void

Completes editing of the CurrentEditItem.

Calls EndEdit if the item implements IEditableObject.

CommitNew ( ) : void

Completes editing of the CurrentAddItem.

Calls EndEdit if the item implements IEditableObject. EntityManager.AddEntity is called to add the item to the EntityManager cache.

Contains ( object item ) : bool

Returns true if the current page contains the specified item.

DeferRefresh ( ) : IDisposable

Called by bound controls when data should be refreshed.

EditItem ( object item ) : void

Make an item the CurrentEditItem.

If the item implements IEditableObject BeginEdit is called.

EntityQueryPagedCollectionView ( EntityQuery query, int pageSize ) : IdeaBlade.Core

Create an instance of this class.

Specify the query which will be executed asynchronously to provide paged results. The "load size", the number of items loaded as each page is request, will default to twice the pageSize value.

EntityQueryPagedCollectionView ( EntityQuery query, int pageSize, int loadSize ) : IdeaBlade.Core

Creates an instance of this class.

Specify the query which will be executed asynchronously to provide paged results. Set pageSize and loadSize to control the number of items displayed and loaded during a page request. If loadSize is a multiple of pageSize then "look ahead" queries are performed to cache page results.

EntityQueryPagedCollectionView ( EntityQuery query, int pageSize, int loadSize, bool deferLoad, bool addPrimaryKeySort ) : IdeaBlade.Core

Create a new instance of this class.

Specify the query which will be executed asynchronously to provide paged results. If the first page should not be immediately loaded set deferLoad to true, and call Refresh() when ready to retrieve data.

GetEnumerator ( ) : IEnumerator

Returns the collection enumerator.

MoveCurrentTo ( object item ) : bool

Selects the indicated item as the CurrentItem.

MoveCurrentToFirst ( ) : bool

Selects the item at position 0 as the CurrentItem.

MoveCurrentToLast ( ) : bool

Selects the last item on the page as the CurrentItem.

MoveCurrentToNext ( ) : bool

Selects the next item as the CurrentItem.

MoveCurrentToPosition ( int position ) : bool

Moves the CurrentPosition to the position indicated.

MoveCurrentToPrevious ( ) : bool

Selects the previous item as the CurrentItem.

MoveToFirstPage ( ) : bool

Move to the first page in the collection.

MoveToLastPage ( ) : bool

Move to the last page in the collection.

MoveToNextPage ( ) : bool

Move to the next page in the collection.

MoveToPage ( int pageIndex ) : bool

Move to the specified 0-based page index.

MoveToPreviousPage ( ) : bool

Move to the previous page in the collection.

Refresh ( ) : void

Re-create the view, using any SortDescriptions, GroupDescriptions and/or filter.

Call Refresh if the EntityQueryPagedCollectionView was created with deferred loading.

RefreshCurrentPage ( ) : void

Reload the current page.

Remove ( object item ) : void

Removes an item from the page and calls Delete on the item.

RemoveAt ( int index ) : void

Removes the item at the specified row index and calls Delete on the item.

SetQueryFilter ( System.Linq.Expressions expression ) : void

Set a filter for this view.

After setting the filter, call Refresh to re-query and load the view.

SetQueryFilter ( IPredicateDescription predicateDescription ) : void

Set a filter for this view.

The filter can be a simple or composite predicate. See the PredicateDescription and PredicateBuilder for more information on building dynamic filter criteria.

After setting the filter, call Refresh to re-query and load the view.

Protected Methods

Method Description
OnCollectionChanged ( NotifyCollectionChangedAction action, object item, int index ) : void

Fires CollectionChanged.

OnCurrentChanged ( ) : void

Fires CurrentChanged.

OnCurrentChanging ( ) : bool

Fires CurrentChanging.

OnPageChanged ( ) : void

Fires PageChanged.

OnPageChanging ( int newPageIndex ) : bool

Fires PageChanging event.

OnPropertyChanged ( string propertyName ) : void

Fires PropertyChanged.

Private Methods

Method Description
AddCachingActions ( int requestedPageIndex, bool includeRequestedPage ) : IEnumerable
BeginTrackPageLoading ( int pageIndex ) : void
BuildFilteredQuery ( ) : EntityQuery
BuildOrderedQuery ( ) : EntityQuery

Build a query with OrderBy, ThenBy operators.

DoGrouping ( ) : void
DoInitialLoad ( ) : void
EndTrackPageLoading ( int pageIndex ) : void
EntityQueryPagedCollectionView ( EntityQuery query, int pageSize, int loadSize, SortDescriptionCollection sortDescriptors, ObservableCollection groupDescriptors, IPredicateDescription filter ) : IdeaBlade.Core
GetLookAheadCount ( int pageSize, int loadSize ) : int
GetMemberExpression ( System.Linq.Expressions parm, string path ) : Expression
GetScalarQuery ( ) : IEntityScalarQuery

Build a scalar query from the original query.

GetSortDescriptionList ( ) : IList
GetTryRefreshPosition ( ) : int
IndexToUserState ( int index ) : string
InitFields ( ) : void
InitialLoadCore ( int beginPageIndex, bool getTotal ) : IEnumerable
IsPageLoadOutstanding ( int pageIndex ) : bool
LoadPage ( int pageIndex ) : void
LoadPageComplete ( EntityQueryOperation args ) : void
MakePagedQuery ( int requestedPageIndex ) : IEntityQuery

Build a paged query based on the current ordered query.

OnPageLoadError ( IBaseOperation op ) : PageLoadErrorEventArgs
ReloadCurrentPage ( ) : void
RemoveItemFromList ( object item, bool isNew ) : void
SetCurrentInfo ( int newPosition ) : bool
SetTotalItemCount ( int count ) : void
ShouldLoadLookAheadPage ( int pageIndex ) : bool
UserStateToIndex ( object userState ) : int

Method Details

AddNew() public method

Creates an item and adds it to the collection for editing.
Calls BeginEdit if the item implements IEditableObject. EntityManager.CreateEntity is used to create the item.
public AddNew ( ) : object
return object

CancelEdit() public method

Cancels editing of the CurrentEditItem.
Calls CancelEdit if the item implements IEditableObject.
public CancelEdit ( ) : void
return void

CancelNew() public method

Cancels editing of the CurrentAddItem.
Calls CancelEdit if the item implements IEditableObject.
public CancelNew ( ) : void
return void

ClearQueryFilter() public method

Can be used to clear the filter.
After clearing the filter, call Refresh to re-query and load the view.

Calling either of the SetQueryFilter(IPredicateDescription) overloads with a null value will also clear the filter.

public ClearQueryFilter ( ) : void
return void

CommitEdit() public method

Completes editing of the CurrentEditItem.
Calls EndEdit if the item implements IEditableObject.
public CommitEdit ( ) : void
return void

CommitNew() public method

Completes editing of the CurrentAddItem.
Calls EndEdit if the item implements IEditableObject. EntityManager.AddEntity is called to add the item to the EntityManager cache.
public CommitNew ( ) : void
return void

Contains() public method

Returns true if the current page contains the specified item.
public Contains ( object item ) : bool
item object
return bool

DeferRefresh() public method

Called by bound controls when data should be refreshed.
public DeferRefresh ( ) : IDisposable
return IDisposable

EditItem() public method

Make an item the CurrentEditItem.
If the item implements IEditableObject BeginEdit is called.
public EditItem ( object item ) : void
item object
return void

EntityQueryPagedCollectionView() public method

Create an instance of this class.
Specify the query which will be executed asynchronously to provide paged results. The "load size", the number of items loaded as each page is request, will default to twice the pageSize value.
public EntityQueryPagedCollectionView ( EntityQuery query, int pageSize ) : IdeaBlade.Core
query EntityQuery The query providing the results to the collection
pageSize int The number of items to be displayed per page
return IdeaBlade.Core

EntityQueryPagedCollectionView() public method

Creates an instance of this class.
Specify the query which will be executed asynchronously to provide paged results. Set pageSize and loadSize to control the number of items displayed and loaded during a page request. If loadSize is a multiple of pageSize then "look ahead" queries are performed to cache page results.
public EntityQueryPagedCollectionView ( EntityQuery query, int pageSize, int loadSize ) : IdeaBlade.Core
query EntityQuery The query providing the results to the collection
pageSize int The number of items to be displayed per page
loadSize int The number of items to be loaded when a page is requested
return IdeaBlade.Core

EntityQueryPagedCollectionView() public method

Create a new instance of this class.
Specify the query which will be executed asynchronously to provide paged results. If the first page should not be immediately loaded set deferLoad to true, and call Refresh() when ready to retrieve data.
public EntityQueryPagedCollectionView ( EntityQuery query, int pageSize, int loadSize, bool deferLoad, bool addPrimaryKeySort ) : IdeaBlade.Core
query EntityQuery The query providing the results to the collection
pageSize int The number of items to be displayed per page
loadSize int The number of items to be loaded when a page is requested
deferLoad bool Whether to defer load
addPrimaryKeySort bool Whether the data should be sorted on primary key
return IdeaBlade.Core

GetEnumerator() public method

Returns the collection enumerator.
public GetEnumerator ( ) : IEnumerator
return IEnumerator

MoveCurrentTo() public method

Selects the indicated item as the CurrentItem.
public MoveCurrentTo ( object item ) : bool
item object
return bool

MoveCurrentToFirst() public method

Selects the item at position 0 as the CurrentItem.
public MoveCurrentToFirst ( ) : bool
return bool

MoveCurrentToLast() public method

Selects the last item on the page as the CurrentItem.
public MoveCurrentToLast ( ) : bool
return bool

MoveCurrentToNext() public method

Selects the next item as the CurrentItem.
public MoveCurrentToNext ( ) : bool
return bool

MoveCurrentToPosition() public method

Moves the CurrentPosition to the position indicated.
public MoveCurrentToPosition ( int position ) : bool
position int
return bool

MoveCurrentToPrevious() public method

Selects the previous item as the CurrentItem.
public MoveCurrentToPrevious ( ) : bool
return bool

MoveToFirstPage() public method

Move to the first page in the collection.
public MoveToFirstPage ( ) : bool
return bool

MoveToLastPage() public method

Move to the last page in the collection.
public MoveToLastPage ( ) : bool
return bool

MoveToNextPage() public method

Move to the next page in the collection.
public MoveToNextPage ( ) : bool
return bool

MoveToPage() public method

Move to the specified 0-based page index.
public MoveToPage ( int pageIndex ) : bool
pageIndex int
return bool

MoveToPreviousPage() public method

Move to the previous page in the collection.
public MoveToPreviousPage ( ) : bool
return bool

OnCollectionChanged() protected method

Fires CollectionChanged.
protected OnCollectionChanged ( NotifyCollectionChangedAction action, object item, int index ) : void
action NotifyCollectionChangedAction
item object
index int
return void

OnCurrentChanged() protected method

Fires CurrentChanged.
protected OnCurrentChanged ( ) : void
return void

OnCurrentChanging() protected method

Fires CurrentChanging.
protected OnCurrentChanging ( ) : bool
return bool

OnPageChanged() protected method

Fires PageChanged.
protected OnPageChanged ( ) : void
return void

OnPageChanging() protected method

Fires PageChanging event.
protected OnPageChanging ( int newPageIndex ) : bool
newPageIndex int
return bool

OnPropertyChanged() protected method

Fires PropertyChanged.
protected OnPropertyChanged ( string propertyName ) : void
propertyName string
return void

Refresh() public method

Re-create the view, using any SortDescriptions, GroupDescriptions and/or filter.
Call Refresh if the EntityQueryPagedCollectionView was created with deferred loading.
public Refresh ( ) : void
return void

RefreshCurrentPage() public method

Reload the current page.
public RefreshCurrentPage ( ) : void
return void

Remove() public method

Removes an item from the page and calls Delete on the item.
public Remove ( object item ) : void
item object
return void

RemoveAt() public method

Removes the item at the specified row index and calls Delete on the item.
public RemoveAt ( int index ) : void
index int
return void

SetQueryFilter() public method

Set a filter for this view.
After setting the filter, call Refresh to re-query and load the view.
public SetQueryFilter ( System.Linq.Expressions expression ) : void
expression System.Linq.Expressions
return void

SetQueryFilter() public method

Set a filter for this view.
The filter can be a simple or composite predicate. See the PredicateDescription and PredicateBuilder for more information on building dynamic filter criteria.

After setting the filter, call Refresh to re-query and load the view.

public SetQueryFilter ( IPredicateDescription predicateDescription ) : void
predicateDescription IPredicateDescription
return void