Skip to content

Commit

Permalink
Moving ITruncatedCollection.IsTruncated after enumeration. Fixes ODat…
Browse files Browse the repository at this point in the history
  • Loading branch information
uffelauesen committed Jan 6, 2025
1 parent 69c9c4f commit e9d5253
Showing 1 changed file with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,9 @@ internal static Func<object, Uri> GetNextLinkGenerator(ODataResourceSetBase reso
{
// nested resourceSet
ITruncatedCollection truncatedCollection = resourceSetInstance as ITruncatedCollection;
if (truncatedCollection != null && truncatedCollection.IsTruncated)
if (truncatedCollection != null)
{
return (obj) => { return GetNestedNextPageLink(writeContext, truncatedCollection.PageSize, obj); };
return (obj) => { return GetNestedNextPageLink(writeContext, truncatedCollection, obj); };
}
}

Expand Down Expand Up @@ -599,9 +599,9 @@ internal static Func<object, Uri> GetNextLinkGenerator(ODataResourceSetBase reso
{
// nested resourceSet
ITruncatedCollection truncatedCollection = resourceSetInstance as ITruncatedCollection;
if (truncatedCollection != null && truncatedCollection.IsTruncated)
if (truncatedCollection != null)
{
return (obj) => { return GetNestedNextPageLink(writeContext, truncatedCollection.PageSize, obj); };
return (obj) => { return GetNestedNextPageLink(writeContext, truncatedCollection, obj); };
}
}

Expand Down Expand Up @@ -695,34 +695,36 @@ private IEnumerable<ODataOperation> CreateODataOperations(IEnumerable<IEdmOperat
}
}

private static Uri GetNestedNextPageLink(ODataSerializerContext writeContext, int pageSize, object obj)
private static Uri GetNestedNextPageLink(ODataSerializerContext writeContext, ITruncatedCollection truncatedCollection, object obj)
{
Contract.Assert(writeContext.ExpandedResource != null);
IEdmNavigationSource sourceNavigationSource = writeContext.ExpandedResource.NavigationSource;
NavigationSourceLinkBuilderAnnotation linkBuilder = writeContext.Model.GetNavigationSourceLinkBuilder(sourceNavigationSource);

Uri navigationLink = linkBuilder.BuildNavigationLink(
writeContext.ExpandedResource,
writeContext.NavigationProperty);
if (truncatedCollection.IsTruncated)
{
IEdmNavigationSource sourceNavigationSource = writeContext.ExpandedResource.NavigationSource;
NavigationSourceLinkBuilderAnnotation linkBuilder = writeContext.Model.GetNavigationSourceLinkBuilder(sourceNavigationSource);

Uri nestedNextLink = GenerateQueryFromExpandedItem(writeContext, navigationLink);
Uri navigationLink = linkBuilder.BuildNavigationLink(
writeContext.ExpandedResource,
writeContext.NavigationProperty);

SkipTokenHandler nextLinkGenerator = null;
if (writeContext.QueryContext != null)
{
nextLinkGenerator = writeContext.QueryContext.GetSkipTokenHandler();
}
Uri nestedNextLink = GenerateQueryFromExpandedItem(writeContext, navigationLink);

if (nestedNextLink != null)
{
if (nextLinkGenerator != null)
SkipTokenHandler nextLinkGenerator = null;
if (writeContext.QueryContext != null)
{
return nextLinkGenerator.GenerateNextPageLink(nestedNextLink, pageSize, obj, writeContext);
nextLinkGenerator = writeContext.QueryContext.GetSkipTokenHandler();
}

return GetNextPageHelper.GetNextPageLink(nestedNextLink, pageSize);
}
if (nestedNextLink != null)
{
if (nextLinkGenerator != null)
{
return nextLinkGenerator.GenerateNextPageLink(nestedNextLink, truncatedCollection.PageSize, obj, writeContext);
}

return GetNextPageHelper.GetNextPageLink(nestedNextLink, truncatedCollection.PageSize);
}
}
return null;
}

Expand Down

0 comments on commit e9d5253

Please sign in to comment.