本文整理汇总了C#中IEdmEntityType.ToTypeReference方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmEntityType.ToTypeReference方法的具体用法?C# IEdmEntityType.ToTypeReference怎么用?C# IEdmEntityType.ToTypeReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmEntityType
的用法示例。
在下文中一共展示了IEdmEntityType.ToTypeReference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddNavigationProperty
/// <summary>Adds a new navigation property.</summary>
/// <param name="entityType">The entity type to add the property to.</param>
/// <param name="name">The name of the property to add.</param>
/// <param name="deleteAction">The delete action of the nav property.</param>
/// <param name="propertyTypeReference">The type of the property to add.</param>
/// <param name="propertyInfo">If this is a CLR property, the <see cref="PropertyInfo"/> for the property, or null otherwise.</param>
/// <param name="containsTarget">The contains target of the nav property</param>
/// <returns>The newly created and added property.</returns>
private IEdmNavigationProperty AddNavigationProperty(
IEdmEntityType entityType,
string name,
EdmOnDeleteAction deleteAction,
IEdmTypeReference propertyTypeReference,
bool containsTarget)
{
// Create a navigation property representing one side of an association.
// The partner representing the other side exists only inside this property and is not added to the target entity type,
// so it should not cause any name collisions.
EdmNavigationProperty navProperty = EdmNavigationProperty.CreateNavigationPropertyWithPartner(
name,
propertyTypeReference,
/*dependentProperties*/ null,
/*principalProperties*/ null,
containsTarget,
deleteAction,
"Partner",
entityType.ToTypeReference(true),
/*partnerDependentProperties*/ null,
/*partnerPrincipalProperties*/ null,
/*partnerContainsTarget*/ false,
EdmOnDeleteAction.None);
((EdmStructuredType)entityType).AddProperty(navProperty);
return navProperty;
}
示例2: AddReferenceProperty
/// <summary>Helper method to add a reference property.</summary>
/// <param name="entityType">The entity type to add the property to.</param>
/// <param name="name">The name of the property to add.</param>
/// <param name="targetEntitySet">The entity set the resource reference property points to.</param>
/// <param name="targetEntityType">The entity type the entity set reference property points to.</param>
/// <param name="resourceSetReference">true if the property should be a entity set reference, false if it should be an entity reference.</param>
private IEdmNavigationProperty AddReferenceProperty(IEdmEntityType entityType, string name, IEdmEntitySet targetEntitySet, IEdmEntityType targetEntityType, bool resourceSetReference, bool containsTarget)
{
targetEntityType = targetEntityType ?? targetEntitySet.EntityType();
IEdmTypeReference navPropertyTypeReference = resourceSetReference
? new EdmCollectionType(targetEntityType.ToTypeReference(true)).ToTypeReference(true)
: targetEntityType.ToTypeReference(true);
IEdmNavigationProperty navigationProperty = AddNavigationProperty(
entityType,
name,
EdmOnDeleteAction.None,
navPropertyTypeReference,
containsTarget);
return navigationProperty;
}
示例3: ODataTypeAnnotation
/// <summary>
/// Creates a new instance of the type annotation for an entity value.
/// </summary>
/// <param name="navigationSource">The navigation source the entity belongs to (required).</param>
/// <param name="entityType">The entity type of the entity value if not the base type of the entity set (optional).</param>
public ODataTypeAnnotation(IEdmNavigationSource navigationSource, IEdmEntityType entityType)
{
ExceptionUtils.CheckArgumentNotNull(entityType, "entityType");
this.navigationSource = navigationSource;
this.type = entityType.ToTypeReference(/*isNullable*/ true);
}