本文整理汇总了C#中IEdmNavigationProperty.DeclaringEntityType方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmNavigationProperty.DeclaringEntityType方法的具体用法?C# IEdmNavigationProperty.DeclaringEntityType怎么用?C# IEdmNavigationProperty.DeclaringEntityType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmNavigationProperty
的用法示例。
在下文中一共展示了IEdmNavigationProperty.DeclaringEntityType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyFeedInNavigationProperty
private void ApplyFeedInNavigationProperty(IEdmNavigationProperty navigationProperty, object entityResource, ODataFeedWithEntries feed, ODataDeserializerContext readContext)
{
Contract.Assert(navigationProperty != null && navigationProperty.PropertyKind == EdmPropertyKind.Navigation, "navigationProperty != null && navigationProperty.TypeKind == ResourceTypeKind.EntityType");
Contract.Assert(entityResource != null, "entityResource != null");
if (readContext.IsDeltaOfT)
{
string message = Error.Format(SRResources.CannotPatchNavigationProperties, navigationProperty.Name, navigationProperty.DeclaringEntityType().FullName());
throw new ODataException(message);
}
ODataEdmTypeDeserializer deserializer = DeserializerProvider.GetEdmTypeDeserializer(navigationProperty.Type);
if (deserializer == null)
{
throw new SerializationException(Error.Format(SRResources.TypeCannotBeDeserialized, navigationProperty.Type.FullName(), typeof(ODataMediaTypeFormatter)));
}
object value = deserializer.ReadInline(feed, navigationProperty.Type, readContext);
string propertyName = EdmLibHelpers.GetClrPropertyName(navigationProperty, readContext.Model);
DeserializationHelpers.SetCollectionProperty(entityResource, navigationProperty, value, propertyName);
}
示例2: ApplyEntryInNavigationProperty
private void ApplyEntryInNavigationProperty(IEdmNavigationProperty navigationProperty, object entityResource, ODataEntryWithNavigationLinks entry, ODataDeserializerContext readContext)
{
Contract.Assert(navigationProperty != null && navigationProperty.PropertyKind == EdmPropertyKind.Navigation, "navigationProperty != null && navigationProperty.TypeKind == ResourceTypeKind.EntityType");
Contract.Assert(entityResource != null, "entityResource != null");
if (readContext.IsPatchMode)
{
string message = Error.Format(SRResources.CannotPatchNavigationProperties, navigationProperty.Name, navigationProperty.DeclaringEntityType().FullName());
throw new ODataException(message);
}
ODataEdmTypeDeserializer deserializer = DeserializerProvider.GetEdmTypeDeserializer(navigationProperty.Type);
if (deserializer == null)
{
throw new SerializationException(Error.Format(SRResources.TypeCannotBeDeserialized, navigationProperty.Type.FullName(), typeof(ODataMediaTypeFormatter)));
}
object value = deserializer.ReadInline(entry, readContext);
DeserializationHelpers.SetProperty(entityResource, navigationProperty.Name, isDelta: false, value: value);
}
示例3: BuildNavigationLink
/// <summary>
/// Constructs a NavigationLink for a particular <see cref="EntityInstanceContext" />, <see cref="IEdmNavigationProperty" /> and <see cref="ODataMetadataLevel" />.
/// </summary>
public virtual Uri BuildNavigationLink(EntityInstanceContext instanceContext, IEdmNavigationProperty navigationProperty, ODataMetadataLevel metadataLevel)
{
if (instanceContext == null)
{
throw Error.ArgumentNull("instanceContext");
}
if (navigationProperty == null)
{
throw Error.ArgumentNull("navigationProperty");
}
NavigationLinkBuilder navigationLinkBuilder;
if (!_navigationPropertyLinkBuilderLookup.TryGetValue(navigationProperty, out navigationLinkBuilder))
{
throw Error.Argument("navigationProperty", SRResources.NoNavigationLinkFactoryFound, navigationProperty.Name, navigationProperty.DeclaringEntityType(), _entitySetName);
}
Contract.Assert(navigationLinkBuilder != null);
if (IsDefaultOrFull(metadataLevel) ||
(IsMinimal(metadataLevel) && !navigationLinkBuilder.FollowsConventions))
{
return navigationLinkBuilder.Factory(instanceContext, navigationProperty);
}
else
{
// client can infer it and didn't ask for it.
return null;
}
}
示例4: BuildNavigationLink
public virtual Uri BuildNavigationLink(EntityInstanceContext context, IEdmNavigationProperty navigationProperty)
{
if (context == null)
{
throw Error.ArgumentNull("context");
}
if (navigationProperty == null)
{
throw Error.ArgumentNull("navigationProperty");
}
Func<EntityInstanceContext, IEdmNavigationProperty, Uri> navigationLinkBuilderFunc;
if (!_navigationPropertyLinkBuilderLookup.TryGetValue(navigationProperty, out navigationLinkBuilderFunc))
{
throw Error.InvalidOperation(SRResources.NoNavigationLinkFactoryFound, navigationProperty.Name, navigationProperty.DeclaringEntityType(), _entitySet.Name);
}
Contract.Assert(navigationLinkBuilderFunc != null);
return navigationLinkBuilderFunc(context, navigationProperty);
}
示例5: GetNavigationChildItem
private static ExplorerItem GetNavigationChildItem(IEdmNavigationProperty property, List<ExplorerItem> schema)
{
var partnerType = property.ToEntityType();
var backReferenceType = partnerType.DeclaredNavigationProperties()
.FirstOrDefault(o => o.ToEntityType() == property.DeclaringEntityType());
var isCollection = property.Type.IsCollection();
var kind = isCollection ? ExplorerItemKind.CollectionLink : ExplorerItemKind.ReferenceLink;
ExplorerIcon icon;
if (backReferenceType == null)
icon = ExplorerIcon.Column;
else if (isCollection)
icon = backReferenceType.Type.IsCollection() ? ExplorerIcon.ManyToMany : ExplorerIcon.OneToMany;
else
icon = backReferenceType.Type.IsCollection() ? ExplorerIcon.ManyToOne : ExplorerIcon.OneToOne;
var item = new ExplorerItem(property.Name, kind, icon)
{
ToolTipText = partnerType.Name,
HyperlinkTarget = schema.FirstOrDefault(a => (IEdmEntityType)a.Tag == partnerType),
DragText = property.Name
};
return item;
}
示例6: GetQualifiedAndEscapedPropertyName
private static string GetQualifiedAndEscapedPropertyName(IEdmNavigationProperty property)
{
object[] objArray = new object[5];
objArray[0] = SerializationExtensionMethods.EscapeName(property.DeclaringEntityType().Namespace).Replace('.', '\u005F');
objArray[1] = (char)95;
objArray[2] = SerializationExtensionMethods.EscapeName(property.DeclaringEntityType().Name);
objArray[3] = (char)95;
objArray[4] = SerializationExtensionMethods.EscapeName(property.Name);
return string.Concat(objArray);
}
示例7: ProcessNavigationProperty
protected override void ProcessNavigationProperty(IEdmNavigationProperty property)
{
EdmSchema edmSchema = null;
string associationNamespace = this.Model.GetAssociationNamespace(property);
if (!this.modelSchemas.TryGetValue(associationNamespace, out edmSchema))
{
edmSchema = new EdmSchema(associationNamespace);
this.modelSchemas.Add(edmSchema.Namespace, edmSchema);
}
edmSchema.AddAssociatedNavigationProperty(property);
edmSchema.AddNamespaceUsing(property.DeclaringEntityType().Namespace);
edmSchema.AddNamespaceUsing(property.Partner.DeclaringEntityType().Namespace);
this.activeSchema.AddNamespaceUsing(associationNamespace);
base.ProcessNavigationProperty(property);
}
示例8: GetQualifiedAndEscapedPropertyName
private static string GetQualifiedAndEscapedPropertyName(IEdmNavigationProperty property)
{
return
EscapeName(property.DeclaringEntityType().Namespace).Replace('.', AssociationNameEscapeChar) +
AssociationNameEscapeChar +
EscapeName(property.DeclaringEntityType().Name) +
AssociationNameEscapeChar +
EscapeName(property.Name);
}
示例9: FindNavigationTarget
/// <summary>
/// Finds the entity set that this navigation property refers to.
/// </summary>
/// <param name="navigationProperty">Instance of navigation property.</param>
/// <returns>an instance of IEdmEntitySet that this navigation property refers to.</returns>
public IEdmNavigationSource FindNavigationTarget(IEdmNavigationProperty navigationProperty)
{
WebUtil.CheckArgumentNull(navigationProperty, "navigationProperty");
MetadataProviderEdmEntitySet targetEntitySet = null;
if (this.navigationTargetMapping == null || !this.navigationTargetMapping.TryGetValue(navigationProperty, out targetEntitySet))
{
string declaringTypeName = navigationProperty.DeclaringEntityType().FullName();
ResourceType declaringResourceType = this.model.MetadataProvider.TryResolveResourceType(declaringTypeName);
ResourceProperty navigationResourceProperty = declaringResourceType.TryResolvePropertiesDeclaredOnThisTypeByName(navigationProperty.Name);
if (navigationResourceProperty != null && navigationResourceProperty.TypeKind == ResourceTypeKind.EntityType)
{
// Calling this method causes the model to load all the metadata for the given association.
// Hence we do not need to add this to the target mapping explicitly
this.model.PairUpNavigationProperty(this.resourceSet, declaringResourceType, navigationResourceProperty);
// Since the entity set or target entity set might be hidden, the navigation target might not get added
// from the previous call
if (this.navigationTargetMapping != null)
{
this.navigationTargetMapping.TryGetValue(navigationProperty, out targetEntitySet);
}
}
}
if (this.model.Mode == MetadataProviderEdmModelMode.SelectAndExpandParsing)
{
// When parsing $select/$expand, the URI parser has no way of knowing which sets are visible. So, if a navigation property is found
// that does not have a target entity set, then it means that the target set is hidden. To avoid disclosing the existence of the set, act
// as if the property does not exist.
if (targetEntitySet == null)
{
// We're playing a dangerous game here. We are trying to throw the SAME ERROR MESSAGE that the Uri Parser would throw
// for some property that is not found. If it looks any different, a client could detect the difference and learn about
// the existance of a navigation property that should have been hidden.
throw DataServiceException.CreateBadRequestError(Strings.BadRequest_InvalidPropertyNameSpecified(navigationProperty.Name, navigationProperty.DeclaringEntityType().FullName()));
}
}
if (this.model.Mode == MetadataProviderEdmModelMode.UriPathParsing)
{
// As with select and expand, when parsing the path, the URI parser has no way of knowing which sets are visible. See above.
if (targetEntitySet == null)
{
// Same fragility as above.
throw DataServiceException.CreateResourceNotFound(navigationProperty.Name);
}
}
return targetEntitySet;
}
示例10: ProcessNavigationProperty
protected override void ProcessNavigationProperty(IEdmNavigationProperty property)
{
var associationNamespace = SerializationExtensionMethods.GetAssociationNamespace(Model, property);
EdmSchema associationSchema;
if (!this.modelSchemas.TryGetValue(associationNamespace, out associationSchema))
{
associationSchema = new EdmSchema(associationNamespace);
this.modelSchemas.Add(associationSchema.Namespace, associationSchema);
}
associationSchema.AddAssociatedNavigationProperty(property);
associationSchema.AddNamespaceUsing(property.DeclaringEntityType().Namespace);
associationSchema.AddNamespaceUsing(property.Partner.DeclaringEntityType().Namespace);
this.activeSchema.AddNamespaceUsing(associationNamespace);
base.ProcessNavigationProperty(property);
}