本文整理汇总了C#中Microsoft.OData.Core.UriParser.Semantic.SelectExpandClause类的典型用法代码示例。如果您正苦于以下问题:C# SelectExpandClause类的具体用法?C# SelectExpandClause怎么用?C# SelectExpandClause使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SelectExpandClause类属于Microsoft.OData.Core.UriParser.Semantic命名空间,在下文中一共展示了SelectExpandClause类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ODataUri
/// <summary>
/// Create a new ODataUri. This contains the semantic meaning of the
/// entire uri.
/// </summary>
/// <param name="parameterAliasValueAccessor">The ParameterAliasValueAccessor.</param>
/// <param name="path">The top level path for this uri.</param>
/// <param name="customQueryOptions">Any custom query options for this uri. Can be null.</param>
/// <param name="selectAndExpand">Any $select or $expand option for this uri. Can be null.</param>
/// <param name="filter">Any $filter option for this uri. Can be null.</param>
/// <param name="orderby">Any $orderby option for this uri. Can be null</param>
/// <param name="search">Any $search option for this uri. Can be null</param>
/// <param name="apply">Any $apply option for this uri. Can be null</param>
/// <param name="skip">Any $skip option for this uri. Can be null.</param>
/// <param name="top">Any $top option for this uri. Can be null.</param>
/// <param name="queryCount">Any query $count option for this uri. Can be null.</param>
internal ODataUri(
ParameterAliasValueAccessor parameterAliasValueAccessor,
ODataPath path,
IEnumerable<QueryNode> customQueryOptions,
SelectExpandClause selectAndExpand,
FilterClause filter,
OrderByClause orderby,
SearchClause search,
ApplyClause apply,
long? skip,
long? top,
bool? queryCount)
{
this.ParameterAliasValueAccessor = parameterAliasValueAccessor;
this.Path = path;
this.CustomQueryOptions = new ReadOnlyCollection<QueryNode>(customQueryOptions.ToList());
this.SelectAndExpand = selectAndExpand;
this.Filter = filter;
this.OrderBy = orderby;
this.Search = search;
this.Apply = apply;
this.Skip = skip;
this.Top = top;
this.QueryCount = queryCount;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:40,代码来源:ODataUri.cs
示例2: SnapResult
private static void SnapResult(List<DeltaSnapshotEntry> results, object entry, IEdmNavigationSource entitySource, SelectExpandClause selectExpandClause, string parentId, string relationShip)
{
var oDataEntry = ODataObjectModelConverter.ConvertToODataEntry(entry, entitySource, ODataVersion.V4);
results.Add(new DeltaSnapshotEntry(oDataEntry.Id.AbsoluteUri, parentId, relationShip));
var expandedNavigationItems = selectExpandClause == null ? null : selectExpandClause.SelectedItems.OfType<ExpandedNavigationSelectItem>();
SnapExpandedEntry(results, entry, entitySource, expandedNavigationItems, oDataEntry.Id.AbsoluteUri);
}
开发者ID:chinadragon0515,项目名称:ODataSamples,代码行数:7,代码来源:DeltaContext.cs
示例3: ValidateRestrictions
private static void ValidateRestrictions(SelectExpandClause selectExpandClause, IEdmModel edmModel)
{
foreach (SelectItem selectItem in selectExpandClause.SelectedItems)
{
ExpandedNavigationSelectItem expandItem = selectItem as ExpandedNavigationSelectItem;
if (expandItem != null)
{
NavigationPropertySegment navigationSegment = (NavigationPropertySegment)expandItem.PathToNavigationProperty.LastSegment;
IEdmNavigationProperty navigationProperty = navigationSegment.NavigationProperty;
if (EdmLibHelpers.IsNotExpandable(navigationProperty, edmModel))
{
throw new ODataException(Error.Format(SRResources.NotExpandablePropertyUsedInExpand, navigationProperty.Name));
}
ValidateRestrictions(expandItem.SelectAndExpand, edmModel);
}
PathSelectItem pathSelectItem = selectItem as PathSelectItem;
if (pathSelectItem != null)
{
ODataPathSegment segment = pathSelectItem.SelectedPath.LastSegment;
NavigationPropertySegment navigationPropertySegment = segment as NavigationPropertySegment;
if (navigationPropertySegment != null)
{
IEdmNavigationProperty navigationProperty = navigationPropertySegment.NavigationProperty;
if (EdmLibHelpers.IsNotNavigable(navigationProperty, edmModel))
{
throw new ODataException(Error.Format(SRResources.NotNavigablePropertyUsedInNavigation, navigationProperty.Name));
}
}
}
}
}
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:32,代码来源:SelectExpandQueryValidator.cs
示例4: Ctor_ThatBuildsNestedContext_CopiesProperties
public void Ctor_ThatBuildsNestedContext_CopiesProperties()
{
// Arrange
CustomersModelWithInheritance model = new CustomersModelWithInheritance();
ODataSerializerContext context = new ODataSerializerContext
{
EntitySet = model.Customers,
MetadataLevel = ODataMetadataLevel.FullMetadata,
Model = model.Model,
Path = new ODataPath(),
Request = new HttpRequestMessage(),
RootElementName = "somename",
SelectExpandClause = new SelectExpandClause(new SelectItem[0], allSelected: true),
SkipExpensiveAvailabilityChecks = true,
Url = new UrlHelper()
};
EntityInstanceContext entity = new EntityInstanceContext { SerializerContext = context };
SelectExpandClause selectExpand = new SelectExpandClause(new SelectItem[0], allSelected: true);
IEdmNavigationProperty navProp = model.Customer.NavigationProperties().First();
// Act
ODataSerializerContext nestedContext = new ODataSerializerContext(entity, selectExpand, navProp);
// Assert
Assert.Equal(context.MetadataLevel, nestedContext.MetadataLevel);
Assert.Same(context.Model, nestedContext.Model);
Assert.Same(context.Path, nestedContext.Path);
Assert.Same(context.Request, nestedContext.Request);
Assert.Equal(context.RootElementName, nestedContext.RootElementName);
Assert.Equal(context.SkipExpensiveAvailabilityChecks, nestedContext.SkipExpensiveAvailabilityChecks);
Assert.Same(context.Url, nestedContext.Url);
}
开发者ID:quentez,项目名称:aspnetwebstack,代码行数:32,代码来源:ODataSerializerContextTest.cs
示例5: SelectBinder
/// <summary>
/// Constructs a new SelectBinder.
/// </summary>
/// <param name="model">The model used for binding.</param>
/// <param name="edmType">The entity type that the $select is being applied to.</param>
/// <param name="maxDepth">the maximum recursive depth.</param>
/// <param name="expandClauseToDecorate">The already built expand clause to decorate</param>
/// <param name="resolver">Resolver for uri parser.</param>
public SelectBinder(IEdmModel model, IEdmStructuredType edmType, int maxDepth, SelectExpandClause expandClauseToDecorate, ODataUriResolver resolver = null)
{
ExceptionUtils.CheckArgumentNotNull(model, "tokenIn");
ExceptionUtils.CheckArgumentNotNull(edmType, "entityType");
this.visitor = new SelectPropertyVisitor(model, edmType, maxDepth, expandClauseToDecorate, resolver);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:15,代码来源:SelectBinder.cs
示例6: AllSelectedIsSetIfSelectIsEmpty
public void AllSelectedIsSetIfSelectIsEmpty()
{
var expandTree = new SelectExpandClause(new Collection<SelectItem>(), false);
var binder = new SelectBinder(HardCodedTestModel.TestModel, HardCodedTestModel.GetPersonType(), 800, expandTree);
var selectToken = new SelectToken(new List<PathSegmentToken>());
binder.Bind(selectToken).AllSelected.Should().BeTrue();
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:7,代码来源:SelectBinderTests.cs
示例7: EnsureMaximumCountAndDepthAreNotExceeded
/// <summary>
/// Recursively ensures that the maximum count/depth are not exceeded by walking the tree.
/// </summary>
/// <param name="expandTree">The expand tree to walk and validate.</param>
/// <param name="currentDepth">The current depth of the tree walk.</param>
private void EnsureMaximumCountAndDepthAreNotExceeded(SelectExpandClause expandTree, int currentDepth)
{
Debug.Assert(expandTree != null, "expandTree != null");
if (currentDepth > this.maxDepth)
{
throw ExceptionUtil.CreateBadRequestError(ODataErrorStrings.UriParser_ExpandDepthExceeded(currentDepth, this.maxDepth));
}
foreach (ExpandedNavigationSelectItem expandItem in expandTree.SelectedItems.Where(I => I.GetType() == typeof(ExpandedNavigationSelectItem)))
{
this.currentCount++;
if (this.currentCount > this.maxCount)
{
throw ExceptionUtil.CreateBadRequestError(ODataErrorStrings.UriParser_ExpandCountExceeded(this.currentCount, this.maxCount));
}
this.EnsureMaximumCountAndDepthAreNotExceeded(expandItem.SelectAndExpand, currentDepth + 1);
}
this.currentCount += expandTree.SelectedItems.Where(I => I.GetType() == typeof(ExpandedReferenceSelectItem)).Count();
if (this.currentCount > this.maxCount)
{
throw ExceptionUtil.CreateBadRequestError(ODataErrorStrings.UriParser_ExpandCountExceeded(this.currentCount, this.maxCount));
}
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:30,代码来源:ExpandDepthAndCountValidator.cs
示例8: WriteEntry
/// <summary>
/// Writes an OData entry.
/// </summary>
/// <param name="writer">The ODataWriter that will write the entry.</param>
/// <param name="element">The item from the data store to write.</param>
/// <param name="navigationSource">The navigation source in the model that the entry belongs to.</param>
/// <param name="model">The data store model.</param>
/// <param name="targetVersion">The OData version this segment is targeting.</param>
/// <param name="selectExpandClause">The SelectExpandClause.</param>
public static void WriteEntry(ODataWriter writer, object element, IEdmNavigationSource entitySource, ODataVersion targetVersion, SelectExpandClause selectExpandClause, Dictionary<string, string> incomingHeaders = null)
{
var entry = ODataObjectModelConverter.ConvertToODataEntry(element, entitySource, targetVersion);
entry.ETag = Utility.GetETagValue(element);
if (selectExpandClause != null && selectExpandClause.SelectedItems.OfType<PathSelectItem>().Any())
{
ExpandSelectItemHandler selectItemHandler = new ExpandSelectItemHandler(entry);
foreach (var item in selectExpandClause.SelectedItems.OfType<PathSelectItem>())
{
item.HandleWith(selectItemHandler);
}
entry = selectItemHandler.ProjectedEntry;
}
CustomizeEntry(incomingHeaders, entry);
writer.WriteStart(entry);
// gets all of the expandedItems, including ExpandedRefernceSelectItem and ExpandedNavigationItem
var expandedItems = selectExpandClause == null ? null : selectExpandClause.SelectedItems.OfType<ExpandedReferenceSelectItem>();
WriteNavigationLinks(writer, element, entry.ReadLink, entitySource, targetVersion, expandedItems);
writer.WriteEnd();
}
开发者ID:vebin,项目名称:odata.net,代码行数:35,代码来源:ResponseWriter.cs
示例9: AddExplicitNavPropLinksWhereNecessary
/// <summary>
/// Add any explicit nav prop links to a select expand clause as necessary.
/// </summary>
/// <param name="clause">the select expand clause to modify.</param>
public static void AddExplicitNavPropLinksWhereNecessary(SelectExpandClause clause)
{
IEnumerable<SelectItem> selectItems = clause.SelectedItems;
// make sure that there are already selects for this level, otherwise we change the select semantics.
bool anyPathSelectItems = selectItems.Any(x => x is PathSelectItem);
// if there are selects for this level, then we need to add nav prop select items for each
// expanded nav prop
IEnumerable<ODataSelectPath> selectedPaths = selectItems.OfType<PathSelectItem>().Select(item => item.SelectedPath);
foreach (ExpandedNavigationSelectItem navigationSelect in selectItems.Where(I => I.GetType() == typeof(ExpandedNavigationSelectItem)))
{
if (anyPathSelectItems && !selectedPaths.Any(x => x.Equals(navigationSelect.PathToNavigationProperty.ToSelectPath())))
{
clause.AddToSelectedItems(new PathSelectItem(navigationSelect.PathToNavigationProperty.ToSelectPath()));
}
AddExplicitNavPropLinksWhereNecessary(navigationSelect.SelectAndExpand);
}
foreach (ExpandedReferenceSelectItem navigationSelect in selectItems.Where(I => I.GetType() == typeof(ExpandedReferenceSelectItem)))
{
if (anyPathSelectItems && !selectedPaths.Any(x => x.Equals(navigationSelect.PathToNavigationProperty.ToSelectPath())))
{
clause.AddToSelectedItems(new PathSelectItem(navigationSelect.PathToNavigationProperty.ToSelectPath()));
}
}
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:32,代码来源:SelectExpandClauseFinisher.cs
示例10: SnapResults
public static void SnapResults(List<DeltaSnapshotEntry> results, IEnumerable entries, IEdmNavigationSource entitySource, SelectExpandClause selectExpandClause, string parentId, string relationShip)
{
foreach (object entry in entries)
{
SnapResult(results, entry, entitySource, selectExpandClause, parentId, relationShip);
}
}
开发者ID:chinadragon0515,项目名称:ODataSamples,代码行数:7,代码来源:DeltaContext.cs
示例11: ODataSerializerContext
/// <summary>
/// Initializes a new instance of the <see cref="ODataSerializerContext"/> class.
/// </summary>
/// <param name="entity">The entity whose navigation property is being expanded.</param>
/// <param name="selectExpandClause">The <see cref="SelectExpandClause"/> for the navigation property being expanded.</param>
/// <param name="navigationProperty">The navigation property being expanded.</param>
/// <remarks>This constructor is used to construct the serializer context for writing expanded properties.</remarks>
public ODataSerializerContext(EntityInstanceContext entity, SelectExpandClause selectExpandClause, IEdmNavigationProperty navigationProperty)
{
if (entity == null)
{
throw Error.ArgumentNull("entity");
}
if (navigationProperty == null)
{
throw Error.ArgumentNull("navigationProperty");
}
ODataSerializerContext context = entity.SerializerContext;
Request = context.Request;
RequestContext = context.RequestContext;
Url = context.Url;
NavigationSource = context.NavigationSource;
Model = context.Model;
Path = context.Path;
RootElementName = context.RootElementName;
SkipExpensiveAvailabilityChecks = context.SkipExpensiveAvailabilityChecks;
MetadataLevel = context.MetadataLevel;
Items = context.Items;
ExpandedEntity = entity;
SelectExpandClause = selectExpandClause;
NavigationProperty = navigationProperty;
NavigationSource = context.NavigationSource.FindNavigationTarget(navigationProperty);
}
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:37,代码来源:ODataSerializerContext.cs
示例12: RootProjectionNode
/// <summary>Creates new root node for the projection tree.</summary>
/// <param name="resourceSetWrapper">The resource set of the root level of the query.</param>
/// <param name="orderingInfo">The ordering info for this node. null means no ordering to be applied.</param>
/// <param name="filter">The filter for this node. null means no filter to be applied.</param>
/// <param name="skipCount">Number of results to skip. null means no results to be skipped.</param>
/// <param name="takeCount">Maximum number of results to return. null means return all available results.</param>
/// <param name="maxResultsExpected">Maximum number of expected results. Hint that the provider should return
/// at least maxResultsExpected + 1 results (if available).</param>
/// <param name="expandPaths">The list of expanded paths.</param>
/// <param name="baseResourceType">The resource type for all entities in this query.</param>
/// <param name="selectExpandClause">The select expand clause for the current node from the URI Parser.</param>
internal RootProjectionNode(
ResourceSetWrapper resourceSetWrapper,
OrderingInfo orderingInfo,
Expression filter,
int? skipCount,
int? takeCount,
int? maxResultsExpected,
List<ExpandSegmentCollection> expandPaths,
ResourceType baseResourceType,
SelectExpandClause selectExpandClause)
: base(
String.Empty,
null,
null,
resourceSetWrapper,
orderingInfo,
filter,
skipCount,
takeCount,
maxResultsExpected,
selectExpandClause)
{
Debug.Assert(baseResourceType != null, "baseResourceType != null");
this.expandPaths = expandPaths;
this.baseResourceType = baseResourceType;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:38,代码来源:RootProjectionNode.cs
示例13: NonSystemTokenTranslatedToSelectionItem
public void NonSystemTokenTranslatedToSelectionItem()
{
var expandTree = new SelectExpandClause(new Collection<SelectItem>(), false);
var binder = new SelectBinder(HardCodedTestModel.TestModel, HardCodedTestModel.GetPersonType(), 800, expandTree);
var selectToken = new SelectToken(new List<PathSegmentToken>() { new NonSystemToken("Shoe", null, null) });
binder.Bind(selectToken).SelectedItems.Single().ShouldBePathSelectionItem(new ODataPath(new PropertySegment(HardCodedTestModel.GetPersonShoeProp())));
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:8,代码来源:SelectBinderTests.cs
示例14: Ctor_ForNestedContext_ThrowsArgumentNull_Entity
public void Ctor_ForNestedContext_ThrowsArgumentNull_Entity()
{
SelectExpandClause selectExpand = new SelectExpandClause(new SelectItem[0], allSelected: true);
IEdmNavigationProperty navProp = new Mock<IEdmNavigationProperty>().Object;
Assert.ThrowsArgumentNull(
() => new ODataSerializerContext(entity: null, selectExpandClause: selectExpand, navigationProperty: navProp), "entity");
}
开发者ID:quentez,项目名称:aspnetwebstack,代码行数:8,代码来源:ODataSerializerContextTest.cs
示例15: SelectPropertyVisitor
/// <summary>
/// Build a property visitor to visit the select tree and decorate a SelectExpandClause
/// </summary>
/// <param name="model">The model used for binding.</param>
/// <param name="edmType">The entity type that the $select is being applied to.</param>
/// <param name="maxDepth">the maximum recursive depth.</param>
/// <param name="expandClauseToDecorate">The already built expand clause to decorate</param>
/// <param name="resolver">Resolver for uri parser.</param>
public SelectPropertyVisitor(IEdmModel model, IEdmStructuredType edmType, int maxDepth, SelectExpandClause expandClauseToDecorate, ODataUriResolver resolver)
{
this.model = model;
this.edmType = edmType;
this.maxDepth = maxDepth;
this.expandClauseToDecorate = expandClauseToDecorate;
this.resolver = resolver ?? ODataUriResolver.Default;
}
开发者ID:TomDu,项目名称:odata.net,代码行数:16,代码来源:SelectPropertyVisitor.cs
示例16: SuccessfullyAddSelectionItems
public void SuccessfullyAddSelectionItems()
{
ODataSelectPath personNamePath = new ODataSelectPath(new PropertySegment(HardCodedTestModel.GetPersonNameProp()));
ODataSelectPath personShoePath = new ODataSelectPath(new PropertySegment(HardCodedTestModel.GetPersonShoeProp()));
var clause = new SelectExpandClause(new List<ExpandedNavigationSelectItem>(), false);
clause.AddToSelectedItems(new PathSelectItem(personShoePath));
clause.AddToSelectedItems(new PathSelectItem(personNamePath));
clause.SelectedItems.Should().HaveCount(2).And.Contain(x => x is PathSelectItem && x.As<PathSelectItem>().SelectedPath == personNamePath).And.Contain(x => x is PathSelectItem && x.As<PathSelectItem>().SelectedPath == personShoePath);
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:9,代码来源:SelectExpandClauseUnitTests.cs
示例17: SelectExpandQueryOption
internal SelectExpandQueryOption(
string select,
string expand,
ODataQueryContext context,
SelectExpandClause selectExpandClause)
: this(select, expand, context)
{
_selectExpandClause = selectExpandClause;
}
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:9,代码来源:SelectExpandQueryOption.cs
示例18: ExistingWildcardPreemptsAnyNewPropertiesAdded
public void ExistingWildcardPreemptsAnyNewPropertiesAdded()
{
var expandTree = new SelectExpandClause(new Collection<SelectItem>()
{
new WildcardSelectItem()
}, false);
var binder = new SelectBinder(HardCodedTestModel.TestModel, HardCodedTestModel.GetPersonType(), 800, expandTree);
var selectToken = new SelectToken(new List<PathSegmentToken>() { new NonSystemToken("Name", null, null) });
binder.Bind(selectToken).SelectedItems.Single().ShouldBeWildcardSelectionItem();
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:10,代码来源:SelectBinderTests.cs
示例19: GenerateDeltaItemsFromFeed
/// <summary>
/// Handle first level entities, genreate the delta items which need to be write
/// </summary>
/// <param name="entries">Query results</param>
/// <param name="entitySet">EntitySet</param>
/// <param name="targetVersion">Target Version</param>
/// <param name="selectExpandClause">Select and Expand Clause</param>
private void GenerateDeltaItemsFromFeed(IEnumerable entries, IEdmNavigationSource entitySet, ODataVersion targetVersion, SelectExpandClause selectExpandClause)
{
foreach (var entry in entries)
{
// Handle single element in first level and their related navigation property
GenerateDeltaItemFromEntry(entry, entitySet, targetVersion, selectExpandClause, string.Empty, string.Empty);
}
// Handle deleted element in first level
GenerateDeltaItemsFromDeletedEntities(string.Empty, string.Empty);
}
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:17,代码来源:DeltaHandler.cs
示例20: ExpandedNavigationPropertiesAreNotAddedAsPathSelectionItemsIfSelectIsNotPopulated
public void ExpandedNavigationPropertiesAreNotAddedAsPathSelectionItemsIfSelectIsNotPopulated()
{
SelectExpandClause clause = new SelectExpandClause(new SelectItem[]
{
new ExpandedNavigationSelectItem(new ODataExpandPath(new NavigationPropertySegment(ModelBuildingHelpers.BuildValidNavigationProperty(), ModelBuildingHelpers.BuildValidEntitySet())), ModelBuildingHelpers.BuildValidEntitySet(), new SelectExpandClause(new List<SelectItem>(), false)),
},
false /*allSelected*/);
SelectExpandClauseFinisher.AddExplicitNavPropLinksWhereNecessary(clause);
clause.SelectedItems.Should().HaveCount(1);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:10,代码来源:SelectExpandClauseFinisherTests.cs
注:本文中的Microsoft.OData.Core.UriParser.Semantic.SelectExpandClause类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论