本文整理汇总了C#中IEdmNavigationSource.FindNavigationTarget方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmNavigationSource.FindNavigationTarget方法的具体用法?C# IEdmNavigationSource.FindNavigationTarget怎么用?C# IEdmNavigationSource.FindNavigationTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmNavigationSource
的用法示例。
在下文中一共展示了IEdmNavigationSource.FindNavigationTarget方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SnapExpandedEntry
private static void SnapExpandedEntry(List<DeltaSnapshotEntry> results, object element, IEdmNavigationSource edmParent, IEnumerable<ExpandedNavigationSelectItem> expandedNavigationItems, string parentId)
{
foreach (var navigationProperty in ((IEdmEntityType)EdmClrTypeUtils.GetEdmType(DataSourceManager.GetCurrentDataSource().Model, element)).NavigationProperties())
{
var expandedNavigationItem = GetExpandedNavigationItem(expandedNavigationItems, navigationProperty.Name);
if (expandedNavigationItem != null)
{
bool isCollection = navigationProperty.Type.IsCollection();
ExpandSelectItemHandler expandItemHandler = new ExpandSelectItemHandler(element);
expandedNavigationItem.HandleWith(expandItemHandler);
var propertyValue = expandItemHandler.ExpandedChildElement;
if (propertyValue != null)
{
IEdmNavigationSource targetSource = edmParent.FindNavigationTarget(navigationProperty);
if (isCollection)
{
SnapResults(results, propertyValue as IEnumerable, targetSource as IEdmEntitySetBase, expandedNavigationItem.SelectAndExpand, parentId, navigationProperty.Name);
}
else
{
SnapResult(results, propertyValue, targetSource, expandedNavigationItem.SelectAndExpand, parentId, navigationProperty.Name);
}
}
}
}
}
示例2: GetNavigationSource
/// <inheritdoc/>
public override IEdmNavigationSource GetNavigationSource(IEdmNavigationSource previousNavigationSource)
{
if (NavigationProperty != null && previousNavigationSource != null)
{
return previousNavigationSource.FindNavigationTarget(NavigationProperty);
}
return null;
}
示例3: WriteNavigationLinks
private static void WriteNavigationLinks(ODataWriter writer, object element, Uri parentEntryUri, IEdmNavigationSource edmParent, ODataVersion targetVersion, IEnumerable<SelectItem> expandedItems)
{
foreach (var navigationProperty in ((IEdmEntityType)EdmClrTypeUtils.GetEdmType(DataSourceManager.GetCurrentDataSource().Model, element)).NavigationProperties())
{
// give proprity to ExpandedReferenceSelectItem
var expandedItem = GetExpandedReferenceItem(expandedItems, navigationProperty.Name);
if (expandedItem == null)
{
expandedItem = GetExpandedNavigationItem(expandedItems, navigationProperty.Name);
}
// For Atom, we always manually write out the links for the navigation properties off of the entity type
// Or if the navigation is expanded, we manually write out the links for the navigation properties along with the expanded entries
if (writer.GetType().Name != "ODataJsonLightWriter" || expandedItem != null)
{
bool isCollection = navigationProperty.Type.IsCollection();
var navigationLink = new ODataNavigationLink
{
IsCollection = isCollection,
Name = navigationProperty.Name,
};
if (writer.GetType().Name == "ODataAtomWriter")
{
//If the passed in parentEntryUri is null then exception will be thrown, to avoid this, create a relative 'potato' Uri.
navigationLink.Url = (parentEntryUri == null) ? new Uri("potato", UriKind.Relative) : new Uri(new Uri(parentEntryUri.AbsoluteUri + "/"), navigationProperty.Name);
}
writer.WriteStart(navigationLink);
if (expandedItem != null)
{
ExpandSelectItemHandler expandItemHandler = new ExpandSelectItemHandler(element);
expandedItem.HandleWith(expandItemHandler);
var propertyValue = expandItemHandler.ExpandedChildElement;
if (propertyValue != null)
{
IEdmNavigationSource targetSource = edmParent.FindNavigationTarget(navigationProperty);
if (isCollection)
{
long? count = null;
var collectionValue = propertyValue as IEnumerable;
if (collectionValue != null && expandedItem.CountOption == true)
{
count = collectionValue.Cast<object>().LongCount();
}
if (expandedItem.GetType() == typeof(ExpandedReferenceSelectItem))
{
WriteReferenceLinks(writer, collectionValue, targetSource as IEdmEntitySetBase, targetVersion, navigationLink);
}
else
{
WriteFeed(writer, collectionValue, targetSource as IEdmEntitySetBase, targetVersion, ((ExpandedNavigationSelectItem)expandedItem).SelectAndExpand, count, null, null);
}
}
else
{
if (expandedItem.GetType() == typeof(ExpandedReferenceSelectItem))
{
WriteReferenceLink(writer, propertyValue, targetSource, targetVersion, navigationLink);
}
else
{
WriteEntry(writer, propertyValue, targetSource, targetVersion, ((ExpandedNavigationSelectItem)expandedItem).SelectAndExpand);
}
}
}
}
writer.WriteEnd();
}
}
}
示例4: GenerateDeltaItemsFromExpand
/// <summary>
/// Handle $expand
/// </summary>
/// <param name="entry">Entry</param>
/// <param name="edmParent">Parent EntitySet</param>
/// <param name="targetVersion">Target Version</param>
/// <param name="expandedNavigationItems">Expand Items</param>
/// <param name="parentId">Parent Id</param>
private void GenerateDeltaItemsFromExpand(object entry, IEdmNavigationSource edmParent, ODataVersion targetVersion, IEnumerable<ExpandedNavigationSelectItem> expandedNavigationItems, string parentId)
{
foreach (var navigationProperty in ((IEdmEntityType)EdmClrTypeUtils.GetEdmType(this.DataSource.Model, entry)).NavigationProperties())
{
var expandedNavigationItem = GetExpandedNavigationItem(expandedNavigationItems, navigationProperty.Name);
if (expandedNavigationItem != null)
{
bool isCollection = navigationProperty.Type.IsCollection();
ExpandSelectItemHandler expandItemHandler = new ExpandSelectItemHandler(entry);
expandedNavigationItem.HandleWith(expandItemHandler);
var propertyValue = expandItemHandler.ExpandedChildElement;
if (propertyValue != null)
{
IEdmNavigationSource targetSource = edmParent.FindNavigationTarget(navigationProperty);
if (isCollection)
{
var expandedEntities = propertyValue as IEnumerable;
foreach (var expandedEntity in expandedEntities)
{
GenerateDeltaItemFromEntry(expandedEntity, targetSource, targetVersion, expandedNavigationItem.SelectAndExpand, parentId, navigationProperty.Name);
}
}
else
{
GenerateDeltaItemFromEntry(propertyValue, targetSource, targetVersion, expandedNavigationItem.SelectAndExpand, parentId, navigationProperty.Name);
}
}
// Handle deleted entry and link here
GenerateDeltaItemsFromDeletedEntities(parentId, navigationProperty.Name);
}
}
}
示例5: GetAutoExpandedNavigationSelectItems
private static IEnumerable<SelectItem> GetAutoExpandedNavigationSelectItems(
IEdmEntityType baseEntityType,
IEdmModel model,
string alreadyExpandedNavigationSourceName,
IEdmNavigationSource navigationSource,
bool isAllSelected,
bool searchDerivedTypeWhenAutoExpand)
{
var expandItems = new List<SelectItem>();
var autoExpandNavigationProperties = EdmLibHelpers.GetAutoExpandNavigationProperties(baseEntityType, model,
searchDerivedTypeWhenAutoExpand);
foreach (var navigationProperty in autoExpandNavigationProperties)
{
if (!alreadyExpandedNavigationSourceName.Equals(navigationProperty.Name))
{
IEdmEntityType entityType = navigationProperty.DeclaringEntityType();
IEdmNavigationSource currentEdmNavigationSource =
navigationSource.FindNavigationTarget(navigationProperty);
if (currentEdmNavigationSource != null)
{
List<ODataPathSegment> pathSegments = new List<ODataPathSegment>()
{
new NavigationPropertySegment(navigationProperty, currentEdmNavigationSource)
};
ODataExpandPath expandPath = new ODataExpandPath(pathSegments);
SelectExpandClause selectExpandClause = new SelectExpandClause(new List<SelectItem>(),
true);
ExpandedNavigationSelectItem item = new ExpandedNavigationSelectItem(expandPath,
currentEdmNavigationSource, selectExpandClause);
if (!currentEdmNavigationSource.EntityType().Equals(entityType))
{
IEnumerable<SelectItem> nestedSelectItems = GetAutoExpandedNavigationSelectItems(
currentEdmNavigationSource.EntityType(),
model,
alreadyExpandedNavigationSourceName,
item.NavigationSource,
true,
searchDerivedTypeWhenAutoExpand);
selectExpandClause = new SelectExpandClause(nestedSelectItems, true);
item = new ExpandedNavigationSelectItem(expandPath, currentEdmNavigationSource,
selectExpandClause);
}
expandItems.Add(item);
if (!isAllSelected)
{
PathSelectItem pathSelectItem = new PathSelectItem(
new ODataSelectPath(pathSegments));
expandItems.Add(pathSelectItem);
}
}
}
}
return expandItems;
}