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
Afficher le fichier Open project: IdeaBlade/DevForce.Utilities Class Usage Examples

Private Properties

Свойство 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

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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

Méthode 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 méthode

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
Résultat object

CancelEdit() public méthode

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

CancelNew() public méthode

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

ClearQueryFilter() public méthode

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
Résultat void

CommitEdit() public méthode

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

CommitNew() public méthode

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
Résultat void

Contains() public méthode

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

DeferRefresh() public méthode

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

EditItem() public méthode

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

EntityQueryPagedCollectionView() public méthode

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
Résultat IdeaBlade.Core

EntityQueryPagedCollectionView() public méthode

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
Résultat IdeaBlade.Core

EntityQueryPagedCollectionView() public méthode

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
Résultat IdeaBlade.Core

GetEnumerator() public méthode

Returns the collection enumerator.
public GetEnumerator ( ) : IEnumerator
Résultat IEnumerator

MoveCurrentTo() public méthode

Selects the indicated item as the CurrentItem.
public MoveCurrentTo ( object item ) : bool
item object
Résultat bool

MoveCurrentToFirst() public méthode

Selects the item at position 0 as the CurrentItem.
public MoveCurrentToFirst ( ) : bool
Résultat bool

MoveCurrentToLast() public méthode

Selects the last item on the page as the CurrentItem.
public MoveCurrentToLast ( ) : bool
Résultat bool

MoveCurrentToNext() public méthode

Selects the next item as the CurrentItem.
public MoveCurrentToNext ( ) : bool
Résultat bool

MoveCurrentToPosition() public méthode

Moves the CurrentPosition to the position indicated.
public MoveCurrentToPosition ( int position ) : bool
position int
Résultat bool

MoveCurrentToPrevious() public méthode

Selects the previous item as the CurrentItem.
public MoveCurrentToPrevious ( ) : bool
Résultat bool

MoveToFirstPage() public méthode

Move to the first page in the collection.
public MoveToFirstPage ( ) : bool
Résultat bool

MoveToLastPage() public méthode

Move to the last page in the collection.
public MoveToLastPage ( ) : bool
Résultat bool

MoveToNextPage() public méthode

Move to the next page in the collection.
public MoveToNextPage ( ) : bool
Résultat bool

MoveToPage() public méthode

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

MoveToPreviousPage() public méthode

Move to the previous page in the collection.
public MoveToPreviousPage ( ) : bool
Résultat bool

OnCollectionChanged() protected méthode

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

OnCurrentChanged() protected méthode

Fires CurrentChanged.
protected OnCurrentChanged ( ) : void
Résultat void

OnCurrentChanging() protected méthode

Fires CurrentChanging.
protected OnCurrentChanging ( ) : bool
Résultat bool

OnPageChanged() protected méthode

Fires PageChanged.
protected OnPageChanged ( ) : void
Résultat void

OnPageChanging() protected méthode

Fires PageChanging event.
protected OnPageChanging ( int newPageIndex ) : bool
newPageIndex int
Résultat bool

OnPropertyChanged() protected méthode

Fires PropertyChanged.
protected OnPropertyChanged ( string propertyName ) : void
propertyName string
Résultat void

Refresh() public méthode

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

RefreshCurrentPage() public méthode

Reload the current page.
public RefreshCurrentPage ( ) : void
Résultat void

Remove() public méthode

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

RemoveAt() public méthode

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

SetQueryFilter() public méthode

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
Résultat void

SetQueryFilter() public méthode

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
Résultat void