本文整理汇总了C#中IEdmModel.HasOwnOrInheritedEpm方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmModel.HasOwnOrInheritedEpm方法的具体用法?C# IEdmModel.HasOwnOrInheritedEpm怎么用?C# IEdmModel.HasOwnOrInheritedEpm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmModel
的用法示例。
在下文中一共展示了IEdmModel.HasOwnOrInheritedEpm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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;
}