本文整理汇总了C#中IEdmEntityType.BaseEntityType方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmEntityType.BaseEntityType方法的具体用法?C# IEdmEntityType.BaseEntityType怎么用?C# IEdmEntityType.BaseEntityType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmEntityType
的用法示例。
在下文中一共展示了IEdmEntityType.BaseEntityType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetIdentifierPrefix
private string GetIdentifierPrefix(IEdmEntityType entityType)
{
if (entityType.BaseEntityType() != null)
{
return GetIdentifierPrefix(entityType.BaseEntityType());
}
TypeMapping existingMapping;
if (_typeUriMap.TryGetValue(entityType.FullName(), out existingMapping))
{
return existingMapping.IdentifierPrefix;
}
var keyList = entityType.DeclaredKey.ToList();
if (keyList.Count != 1)
{
// Ignore this entity
// TODO: Log an error
return null;
}
var identifierPrefix = GetStringAnnotationValue(keyList.First(), AnnotationsNamespace, "IdentifierPrefix");
if (identifierPrefix == null)
{
// TODO: Log an error
}
return identifierPrefix;
}
示例2: ProcessEntityType
protected override void ProcessEntityType(IEdmEntityType element)
{
base.ProcessEntityType(element);
if (element.BaseEntityType() != null)
{
this.CheckSchemaElementReference(element.BaseEntityType());
}
}
示例3: EnsureEpmCacheInternal
private static ODataEntityPropertyMappingCache EnsureEpmCacheInternal(IEdmModel model, IEdmEntityType entityType, int maxMappingCount, out bool cacheModified)
{
cacheModified = false;
if (entityType == null)
{
return null;
}
IEdmEntityType type = entityType.BaseEntityType();
ODataEntityPropertyMappingCache baseCache = null;
if (type != null)
{
baseCache = EnsureEpmCacheInternal(model, type, maxMappingCount, out cacheModified);
}
ODataEntityPropertyMappingCache epmCache = model.GetEpmCache(entityType);
if (model.HasOwnOrInheritedEpm(entityType))
{
ODataEntityPropertyMappingCollection entityPropertyMappings = model.GetEntityPropertyMappings(entityType);
if (!(((epmCache == null) || cacheModified) || epmCache.IsDirty(entityPropertyMappings)))
{
return epmCache;
}
cacheModified = true;
int totalMappingCount = ValidationUtils.ValidateTotalEntityPropertyMappingCount(baseCache, entityPropertyMappings, maxMappingCount);
epmCache = new ODataEntityPropertyMappingCache(entityPropertyMappings, model, totalMappingCount);
try
{
epmCache.BuildEpmForType(entityType, entityType);
epmCache.EpmSourceTree.Validate(entityType);
model.SetAnnotationValue<ODataEntityPropertyMappingCache>(entityType, epmCache);
return epmCache;
}
catch
{
model.RemoveEpmCache(entityType);
throw;
}
}
if (epmCache != null)
{
cacheModified = true;
model.RemoveEpmCache(entityType);
}
return epmCache;
}
示例4: BuildEpmForType
internal void BuildEpmForType(IEdmEntityType definingEntityType, IEdmEntityType affectedEntityType)
{
if (definingEntityType.BaseType != null)
{
this.BuildEpmForType(definingEntityType.BaseEntityType(), affectedEntityType);
}
ODataEntityPropertyMappingCollection entityPropertyMappings = this.model.GetEntityPropertyMappings(definingEntityType);
if (entityPropertyMappings != null)
{
foreach (EntityPropertyMappingAttribute attribute in entityPropertyMappings)
{
this.epmSourceTree.Add(new EntityPropertyMappingInfo(attribute, definingEntityType, affectedEntityType));
if ((definingEntityType == affectedEntityType) && !PropertyExistsOnType(affectedEntityType, attribute))
{
this.MappingsForInheritedProperties.Add(attribute);
this.MappingsForDeclaredProperties.Remove(attribute);
}
}
}
}
示例5: AssertEntityTypeIsDerivedFrom
/// <summary>
/// Asserts that a given entity type is derived from the specified base entity type.
/// </summary>
/// <param name="derivedType">The derived entity type.</param>
/// <param name="baseType">The base entity type.</param>
public static void AssertEntityTypeIsDerivedFrom(IEdmEntityType derivedType, IEdmEntityType baseType)
{
ExceptionUtilities.CheckArgumentNotNull(derivedType, "derivedType");
ExceptionUtilities.CheckArgumentNotNull(baseType, "baseType");
if (derivedType == baseType)
{
return;
}
var entityType = derivedType.BaseEntityType();
while (entityType != null)
{
if (entityType == baseType)
{
return;
}
entityType = entityType.BaseEntityType();
}
ExceptionUtilities.Assert(false, "Expected entity type " + derivedType.FullName() + " to be derived from " + baseType.FullName());
}
示例6: FindBest
// Performs overload resolution between a set of matching bindable actions. OData protocol ensures that there
// cannot be multiple bindable actions with same name and different sets of non-bindable paramters.
// The resolution logic is simple and is dependant only on the binding parameter and chooses the action that is defined
// closest to the binding parameter in the inheritance hierarchy.
private static IEdmFunctionImport FindBest(string actionIdentifier, IEnumerable<IEdmFunctionImport> bindableActions,
IEdmEntityType bindingParameterType, bool isCollection)
{
if (bindingParameterType == null)
{
return null;
}
List<IEdmFunctionImport> actionsBoundToThisType = new List<IEdmFunctionImport>();
foreach (IEdmFunctionImport action in bindableActions)
{
IEdmType actionParameterType = action.Parameters.First().Type.Definition;
if (isCollection)
{
actionParameterType = ((IEdmCollectionType)actionParameterType).ElementType.Definition;
}
if (actionParameterType == bindingParameterType)
{
actionsBoundToThisType.Add(action);
}
}
if (actionsBoundToThisType.Count > 1)
{
throw Error.Argument(
"actionIdentifier",
SRResources.ActionResolutionFailed,
actionIdentifier,
String.Join(", ", actionsBoundToThisType.Select(match => match.Container.FullName() + "." + match.Name)));
}
else if (actionsBoundToThisType.Count == 1)
{
return actionsBoundToThisType[0];
}
else
{
return FindBest(actionIdentifier, bindableActions, bindingParameterType.BaseEntityType(), isCollection);
}
}
示例7: EnsureEpmCacheInternal
/// <summary>
/// Ensures that an up-to-date EPM cache exists for the specified <paramref name="entityType"/>.
/// If no cache exists, a new one will be created based on the public mappings (if any).
/// If the public mappings have changed (and the cache is thus dirty), the method re-constructs the cache.
/// If all public mappings have been removed, the method also removes the EPM cache.
/// </summary>
/// <param name="model">IEdmModel instance containing the annotations.</param>
/// <param name="entityType">IEdmEntityType instance for which to ensure the EPM cache.</param>
/// <param name="maxMappingCount">The maximum allowed number of entity property mappings
/// for a given entity type (on the type itself and all its base types).</param>
/// <param name="cacheModified">true if the cache was modified; otherwise false.</param>
/// <returns>An instance of <see cref="ODataEntityPropertyMappingCache"/>, if there are any EPM mappings for the given entity type, otherwise returns null.</returns>
private static ODataEntityPropertyMappingCache EnsureEpmCacheInternal(
IEdmModel model,
IEdmEntityType entityType,
int maxMappingCount,
out bool cacheModified)
{
cacheModified = false;
if (entityType == null)
{
return null;
}
// Make sure the EPM of the base type is initialized.
IEdmEntityType baseEntityType = entityType.BaseEntityType();
ODataEntityPropertyMappingCache baseCache = null;
if (baseEntityType != null)
{
baseCache = EnsureEpmCacheInternal(model, baseEntityType, maxMappingCount, out cacheModified);
}
ODataEntityPropertyMappingCache epmCache = model.GetEpmCache(entityType);
if (model.HasOwnOrInheritedEpm(entityType))
{
ODataEntityPropertyMappingCollection mappings = model.GetEntityPropertyMappings(entityType);
bool needToBuildCache = epmCache == null || cacheModified || epmCache.IsDirty(mappings);
if (needToBuildCache)
{
cacheModified = true;
int totalMappingCount = ValidationUtils.ValidateTotalEntityPropertyMappingCount(baseCache, mappings, maxMappingCount);
epmCache = new ODataEntityPropertyMappingCache(mappings, model, totalMappingCount);
// Build the EPM tree and validate it
try
{
epmCache.BuildEpmForType(entityType, entityType);
epmCache.EpmSourceTree.Validate(entityType);
epmCache.EpmTargetTree.Validate();
// We set the annotation here, so if anything fails during
// building of the cache the annotation will not even be set so
// not leaving the type in an inconsistent state.
model.SetAnnotationValue(entityType, epmCache);
}
catch
{
// Remove an existing EPM cache if it is dirty to make sure we don't leave
// stale caches in case building of the cache fails.
// NOTE: we do this in the catch block to ensure that we always make a single
// SetAnnotation call to either set or clear the existing annotation
// since the SetAnnotation method is thread-safe
model.RemoveEpmCache(entityType);
throw;
}
}
}
else
{
if (epmCache != null)
{
// remove an existing EPM cache if the mappings have been removed from the type
cacheModified = true;
model.RemoveEpmCache(entityType);
}
}
return epmCache;
}
示例8: HasOwnOrInheritedEpm
/// <summary>
/// Checks whether the <paramref name="entityType"/> has EPM defined for it (either directly
/// on the type or on one of the base types).
/// </summary>
/// <param name="model">The <see cref="IEdmModel"/> containing the annotation.</param>
/// <param name="entityType">The <see cref="IEdmEntityType"/> to check.</param>
/// <returns>true if the <paramref name="entityType"/> has EPM defined; otherwise false.</returns>
private static bool HasOwnOrInheritedEpm(this IEdmModel model, IEdmEntityType entityType)
{
if (entityType == null)
{
return false;
}
Debug.Assert(model != null, "model != null");
if (model.GetAnnotationValue<ODataEntityPropertyMappingCollection>(entityType) != null)
{
return true;
}
// If we don't have an in-memory annotation, try to load the serializable EPM annotations
LoadEpmAnnotations(model, entityType);
if (model.GetAnnotationValue<ODataEntityPropertyMappingCollection>(entityType) != null)
{
return true;
}
return model.HasOwnOrInheritedEpm(entityType.BaseEntityType());
}
示例9: IsDerivedTypeOf
// returns -1 if type does not derive from baseType and a positive number representing the distance
// between them if it does.
private static int IsDerivedTypeOf(IEdmEntityType type, IEdmEntityType baseType)
{
int distance = 0;
while (type != null)
{
if (baseType == type)
{
return distance;
}
type = type.BaseEntityType();
distance++;
}
return -1;
}
示例10: ConvertToTaupoEntityType
private EntityType ConvertToTaupoEntityType(IEdmEntityType edmEntityType)
{
var taupoEntityType = new EntityType(edmEntityType.Namespace, edmEntityType.Name)
{
IsAbstract = edmEntityType.IsAbstract,
IsOpen = edmEntityType.IsOpen,
};
if (edmEntityType.BaseType != null)
{
taupoEntityType.BaseType = new EntityTypeReference(edmEntityType.BaseEntityType().Namespace, edmEntityType.BaseEntityType().Name);
}
foreach (var edmProperty in edmEntityType.DeclaredStructuralProperties())
{
var taupoProperty = this.ConvertToTaupoProperty(edmProperty);
taupoProperty.IsPrimaryKey = edmEntityType.Key().Contains(edmProperty);
taupoEntityType.Add(taupoProperty);
}
this.ConvertAnnotationsIntoTaupo(edmEntityType, taupoEntityType);
return taupoEntityType;
}
示例11: HasOwnOrInheritedEpm
private static bool HasOwnOrInheritedEpm(this IEdmModel model, IEdmEntityType entityType)
{
if (entityType == null)
{
return false;
}
if (model.GetAnnotationValue<ODataEntityPropertyMappingCollection>(entityType) != null)
{
return true;
}
LoadEpmAnnotations(model, entityType);
return ((model.GetAnnotationValue<ODataEntityPropertyMappingCollection>(entityType) != null) || model.HasOwnOrInheritedEpm(entityType.BaseEntityType()));
}
示例12: BuildEpmForType
/// <summary>
/// Initializes the EPM annotation with EPM information from the specified type.
/// </summary>
/// <param name="definingEntityType">Entity type to use the EPM infromation from.</param>
/// <param name="affectedEntityType">Entity type for this the EPM information is being built.</param>
internal void BuildEpmForType(IEdmEntityType definingEntityType, IEdmEntityType affectedEntityType)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(definingEntityType != null, "definingEntityType != null");
Debug.Assert(affectedEntityType != null, "affectedEntityType != null");
if (definingEntityType.BaseType != null)
{
this.BuildEpmForType(definingEntityType.BaseEntityType(), affectedEntityType);
}
ODataEntityPropertyMappingCollection mappingsForType = this.model.GetEntityPropertyMappings(definingEntityType);
if (mappingsForType == null)
{
return;
}
foreach (EntityPropertyMappingAttribute mapping in mappingsForType)
{
this.epmSourceTree.Add(new EntityPropertyMappingInfo(mapping, definingEntityType, affectedEntityType));
if (definingEntityType == affectedEntityType)
{
if (!PropertyExistsOnType(affectedEntityType, mapping))
{
this.MappingsForInheritedProperties.Add(mapping);
this.MappingsForDeclaredProperties.Remove(mapping);
}
}
}
}