Skip to content

Commit

Permalink
Reset paging on multiple executions
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMpn committed Jan 4, 2022
1 parent f3b0c49 commit 932a212
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions MarkMpn.Sql4Cds.Engine/ExecutionPlan/FetchXmlScan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public void SetValue(object value, IQueryExecutionOptions options)
private string _lastSchemaFetchXml;
private string _lastSchemaAlias;
private NodeSchema _lastSchema;
private bool _resetPage;
private string _startingPage;

public FetchXmlScan()
{
Expand Down Expand Up @@ -172,6 +174,19 @@ protected override IEnumerable<Entity> ExecuteInternal(IDictionary<string, DataS

// Get the first page of results
options.RetrievingNextPage();

// Ensure we reset the page number & cookie for subsequent executions
if (_resetPage)
{
FetchXml.page = _startingPage;
FetchXml.pagingcookie = null;
}
else
{
_startingPage = FetchXml.page;
_resetPage = true;
}

var res = dataSource.Connection.RetrieveMultiple(new FetchExpression(Serialize(FetchXml)));
PagesRetrieved++;

Expand Down

0 comments on commit 932a212

Please sign in to comment.