Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ICountOptionCollection public. Fixes #1382. #1383

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.OData.Query;
/// <summary>
/// Represents a collection that has total count.
/// </summary>
internal interface ICountOptionCollection : IEnumerable
public interface ICountOptionCollection : IEnumerable
{
/// <summary>
/// Gets a value representing the total count of the collection.
Expand Down