/// <summary> /// Turns the in-memory representations of the supported, OData-specific annotations into their serializable form. /// Assumes that the entity type and the model have been validated. /// </summary> /// <param name="model">The <see cref="IEdmModel"/> containing the annotations.</param> /// <param name="entityType">The <see cref="IEdmEntityType"/> to process.</param> private static void SaveODataAnnotationsImplementation(IEdmModel model, IEdmEntityType entityType) { Debug.Assert(model != null, "model != null"); Debug.Assert(entityType != null, "entityType != null"); // Get the cached EPM information for this entity type; if the mappings have changed this will update the cache; // if all the mappings have been removed, we will delete the cache. // Building the cache will also validate the EPM (since we don't want to save/write invalid EPM information). // NOTE: when saving annotations on a model we assume it is valid and thus pass int.MaxValue for the maxMappingCount. ODataEntityPropertyMappingCache epmCache = model.EnsureEpmCache(entityType, /*maxMappingCount*/ int.MaxValue); if (epmCache != null) { // write any mappings for properties that are not declared on this type on the entity type model.SaveEpmAnnotations(entityType, epmCache.MappingsForInheritedProperties, false, false); IEnumerable <IEdmProperty> declaredProperties = entityType.DeclaredProperties; if (declaredProperties != null) { foreach (IEdmProperty property in declaredProperties) { if (property.Type.IsODataPrimitiveTypeKind() || property.Type.IsODataComplexTypeKind()) { model.SaveEpmAnnotationsForProperty(property, epmCache); } else if (property.Type.IsNonEntityODataCollectionTypeKind()) { model.SaveEpmAnnotationsForProperty(property, epmCache); } } } } }
public static void LoadODataAnnotations(this IEdmModel model, IEdmEntityType entityType, int maxEntityPropertyMappingsPerType) { ExceptionUtils.CheckArgumentNotNull <IEdmModel>(model, "model"); ExceptionUtils.CheckArgumentNotNull <IEdmEntityType>(entityType, "entityType"); model.ClearInMemoryEpmAnnotations(entityType); model.EnsureEpmCache(entityType, maxEntityPropertyMappingsPerType); }
/// <summary> /// Loads the supported, OData-specific serializable annotations into their in-memory representations. /// </summary> /// <param name="model">The <see cref="IEdmModel"/> containing the annotations.</param> /// <param name="entityType">The <see cref="IEdmEntityType"/> to process.</param> /// <param name="maxEntityPropertyMappingsPerType">The maximum number of entity mapping attributes to be found /// for an entity type (on the type itself and all its base types).</param> public static void LoadODataAnnotations(this IEdmModel model, IEdmEntityType entityType, int maxEntityPropertyMappingsPerType) { ExceptionUtils.CheckArgumentNotNull(model, "model"); ExceptionUtils.CheckArgumentNotNull(entityType, "entityType"); // PERF: should we be smarter and only update existing annotations as needed (and only drop the caches if needed)? // remove any existing in-memory EPM annotations and EPM caches on the entity type model.ClearInMemoryEpmAnnotations(entityType); // NOTE: EnsureEpmCache will load the serializable EPM annotations if no in-memory annotations exist. model.EnsureEpmCache(entityType, maxEntityPropertyMappingsPerType); }
private static void SaveODataAnnotationsImplementation(IEdmModel model, IEdmEntityType entityType) { ODataEntityPropertyMappingCache epmCache = model.EnsureEpmCache(entityType, 0x7fffffff); if (epmCache != null) { model.SaveEpmAnnotations(entityType, epmCache.MappingsForInheritedProperties, false, false); IEnumerable <IEdmProperty> declaredProperties = entityType.DeclaredProperties; if (declaredProperties != null) { foreach (IEdmProperty property in declaredProperties) { if (property.Type.IsODataPrimitiveTypeKind() || property.Type.IsODataComplexTypeKind()) { model.SaveEpmAnnotationsForProperty(property, epmCache); } else if (property.Type.IsNonEntityODataCollectionTypeKind()) { model.SaveEpmAnnotationsForProperty(property, epmCache); } } } } }
/// <summary> /// Turns the in-memory representations of the supported, OData-specific annotations into their serializable form. /// Assumes that the entity type and the model have been validated. /// </summary> /// <param name="model">The <see cref="IEdmModel"/> containing the annotations.</param> /// <param name="entityType">The <see cref="IEdmEntityType"/> to process.</param> private static void SaveODataAnnotationsImplementation(IEdmModel model, IEdmEntityType entityType) { Debug.Assert(model != null, "model != null"); Debug.Assert(entityType != null, "entityType != null"); // Get the cached EPM information for this entity type; if the mappings have changed this will update the cache; // if all the mappings have been removed, we will delete the cache. // Building the cache will also validate the EPM (since we don't want to save/write invalid EPM information). // NOTE: when saving annotations on a model we assume it is valid and thus pass int.MaxValue for the maxMappingCount. ODataEntityPropertyMappingCache epmCache = model.EnsureEpmCache(entityType, /*maxMappingCount*/ int.MaxValue); if (epmCache != null) { // write any mappings for properties that are not declared on this type on the entity type model.SaveEpmAnnotations(entityType, epmCache.MappingsForInheritedProperties, false, false); IEnumerable<IEdmProperty> declaredProperties = entityType.DeclaredProperties; if (declaredProperties != null) { foreach (IEdmProperty property in declaredProperties) { if (property.Type.IsODataPrimitiveTypeKind() || property.Type.IsODataComplexTypeKind()) { model.SaveEpmAnnotationsForProperty(property, epmCache); } else if (property.Type.IsNonEntityODataCollectionTypeKind()) { model.SaveEpmAnnotationsForProperty(property, epmCache); } } } } }
private static void SaveODataAnnotationsImplementation(IEdmModel model, IEdmEntityType entityType) { ODataEntityPropertyMappingCache epmCache = model.EnsureEpmCache(entityType, 0x7fffffff); if (epmCache != null) { model.SaveEpmAnnotations(entityType, epmCache.MappingsForInheritedProperties, false, false); IEnumerable<IEdmProperty> declaredProperties = entityType.DeclaredProperties; if (declaredProperties != null) { foreach (IEdmProperty property in declaredProperties) { if (property.Type.IsODataPrimitiveTypeKind() || property.Type.IsODataComplexTypeKind()) { model.SaveEpmAnnotationsForProperty(property, epmCache); } else if (property.Type.IsNonEntityODataCollectionTypeKind()) { model.SaveEpmAnnotationsForProperty(property, epmCache); } } } } }