-
Notifications
You must be signed in to change notification settings - Fork 352
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
Add support for $count in navigation properties #2051
Changes from all commits
3765baf
8f28347
48ce526
cfa2fb0
88baf1b
b4c88d3
ed2516e
991d56d
c62f79f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//--------------------------------------------------------------------- | ||
// <copyright file="ExpandedCountSelectItem.cs" company="Microsoft"> | ||
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. | ||
// </copyright> | ||
//--------------------------------------------------------------------- | ||
|
||
namespace Microsoft.OData.UriParser | ||
{ | ||
using Aggregation; | ||
using Microsoft.OData.Edm; | ||
|
||
/// <summary> | ||
/// This represents one level of expansion for a particular expansion tree. | ||
/// </summary> | ||
public sealed class ExpandedCountSelectItem : ExpandedReferenceSelectItem | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think it's better to derive from ExpandedReferenceSelectItem? Or shall we have a base NavigationSelectItem, and others derived from it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The semantics are the same though. |
||
{ | ||
/// <summary> | ||
/// Create an Expand item using a nav prop, its entity set and a SelectExpandClause | ||
/// </summary> | ||
/// <param name="pathToNavigationProperty">the path to the navigation property for this expand item, including any type segments</param> | ||
/// <param name="navigationSource">the navigation source for this ExpandItem</param> | ||
/// <param name="filterOption">A filter clause for this expand (can be null)</param> | ||
/// <param name="searchOption">A search clause for this expand (can be null)</param> | ||
/// <exception cref="System.ArgumentNullException">Throws if input pathToNavigationProperty is null.</exception> | ||
public ExpandedCountSelectItem(ODataExpandPath pathToNavigationProperty, IEdmNavigationSource navigationSource, FilterClause filterOption, SearchClause searchOption) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only $filter and $search are allowed within nav/$count? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes: From the protocol http://docs.oasis-open.org/odata/odata/v4.01/cs01/part1-protocol/odata-v4.01-cs01-part1-protocol.html#sec_RequestingtheNumberofItemsinaCollect On success, the response body MUST contain the exact count of items matching the request after applying any $filter or $search system query options, formatted as a simple primitive integer value with media type text/plain. Clients SHOULD NOT combine the system query options $top, $skip, $orderby, $expand, and $format with the path suffix /$count. The result of such a request is undefined.
Comment on lines
+17
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be helpful if you could provide an concrete example of a path that this class represents, and how the parts of the path that the different parameters represent. |
||
: base(pathToNavigationProperty, navigationSource, filterOption, null, null, null, null, searchOption) | ||
{ | ||
ExceptionUtils.CheckArgumentNotNull(pathToNavigationProperty, "pathToNavigationProperty"); | ||
} | ||
|
||
/// <summary> | ||
/// Translate using a <see cref="SelectItemTranslator{T}"/>. | ||
/// </summary> | ||
/// <typeparam name="T">Type that the translator will return after visiting this item.</typeparam> | ||
/// <param name="translator">An implementation of the translator interface.</param> | ||
/// <returns>An object whose type is determined by the type parameter of the translator.</returns> | ||
/// <exception cref="System.ArgumentNullException">Throws if the input translator is null.</exception> | ||
public override T TranslateWith<T>(SelectItemTranslator<T> translator) | ||
{ | ||
return translator.Translate(this); | ||
} | ||
|
||
/// <summary> | ||
/// Handle using a <see cref="SelectItemHandler"/>. | ||
/// </summary> | ||
/// <param name="handler">An implementation of the handler interface.</param> | ||
/// <exception cref="System.ArgumentNullException">Throws if the input handler is null.</exception> | ||
public override void HandleWith(SelectItemHandler handler) | ||
{ | ||
handler.Handle(this); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain the logic here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Path segment starts with
$
, it should only have$count
or$ref
whenallowRef
istrue
e.g
$expand=NavProp/$ref
$expand=NavProp/$count