/// <inheritdoc /> public override EntitySetConfiguration AddEntitySet(string name, EntityTypeConfiguration entityType) { EntitySetConfiguration entitySetConfiguration = base.AddEntitySet(name, entityType); if (_isModelBeingBuilt) { ApplyNavigationSourceConventions(entitySetConfiguration); } return(entitySetConfiguration); }
/// <summary> /// Sets the return type to a single EntityType instance. /// </summary> /// <typeparam name="TEntityType">The type that is an EntityType</typeparam> /// <param name="entitySetConfiguration">The entity set which contains the returned entity.</param> public ActionConfiguration ReturnsFromEntitySet <TEntityType>(EntitySetConfiguration <TEntityType> entitySetConfiguration) where TEntityType : class { if (entitySetConfiguration == null) { throw Error.ArgumentNull("entitySetConfiguration"); } NavigationSource = entitySetConfiguration.EntitySet; ReturnType = ModelBuilder.GetTypeConfigurationOrNull(typeof(TEntityType)); return(this); }
/// <summary> /// Removes the entity set from the model. /// </summary> /// <param name="name">The name of the entity set to be removed.</param> /// <returns><c>true</c> if the entity set is present in the model and <c>false</c> otherwise.</returns> public virtual bool RemoveEntitySet(string name) { if (_navigationSources.ContainsKey(name)) { EntitySetConfiguration entitySet = _navigationSources[name] as EntitySetConfiguration; if (entitySet != null) { return(_navigationSources.Remove(name)); } } return(false); }
/// <summary> /// Sets the return type to a collection of entities. /// </summary> /// <typeparam name="TElementEntityType">The entity type.</typeparam> /// <param name="entitySetConfiguration">The entity set which contains the returned entities.</param> public ActionConfiguration ReturnsCollectionFromEntitySet <TElementEntityType>( EntitySetConfiguration <TElementEntityType> entitySetConfiguration) where TElementEntityType : class { if (entitySetConfiguration == null) { throw Error.ArgumentNull("entitySetConfiguration"); } Type clrCollectionType = typeof(IEnumerable <TElementEntityType>); NavigationSource = entitySetConfiguration.EntitySet; IEdmTypeConfiguration elementType = ModelBuilder.GetTypeConfigurationOrNull(typeof(TElementEntityType)); ReturnType = new CollectionTypeConfiguration(elementType, clrCollectionType); return(this); }
/// <summary> /// Registers an entity set as a part of the model and returns an object that can be used to configure the entity set. /// This method can be called multiple times for the same type to perform multiple lines of configuration. /// </summary> /// <param name="name">The name of the entity set.</param> /// <param name="entityType">The type to be registered or configured.</param> /// <returns>The configuration object for the specified entity set.</returns> public virtual EntitySetConfiguration AddEntitySet(string name, EntityTypeConfiguration entityType) { if (String.IsNullOrWhiteSpace(name)) { throw Error.ArgumentNullOrEmpty("name"); } if (entityType == null) { throw Error.ArgumentNull("entityType"); } if (name.Contains(".")) { throw Error.NotSupported(SRResources.InvalidEntitySetName, name); } EntitySetConfiguration entitySet = null; if (_navigationSources.ContainsKey(name)) { entitySet = _navigationSources[name] as EntitySetConfiguration; if (entitySet == null) { throw Error.Argument("name", SRResources.EntitySetNameAlreadyConfiguredAsSingleton, name); } if (entitySet.EntityType != entityType) { throw Error.Argument("entityType", SRResources.EntitySetAlreadyConfiguredDifferentEntityType, entitySet.Name, entitySet.EntityType.Name); } } else { entitySet = new EntitySetConfiguration(this, entityType, name); _navigationSources[name] = entitySet; } return(entitySet); }
/// <summary> /// <see cref="SkipSupportedConfiguration"/> configuration /// </summary> /// <typeparam name="TEntity">The entity type of the navigation source.</typeparam> /// <param name="navigationSource">The <see cref="IEdmNavigationSource"/> that can be built using <see cref="ODataModelBuilder"/>.</param> /// <returns><see cref="SkipSupportedConfiguration"/></returns> public static SkipSupportedConfiguration HasSkipSupported <TEntity>(this EntitySetConfiguration <TEntity> navigationSource) where TEntity : class => navigationSource?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration <SkipSupportedConfiguration>();
/// <summary> /// <see cref="IndexableByKeyConfiguration"/> configuration /// </summary> /// <typeparam name="TEntity">The entity type of the navigation source.</typeparam> /// <param name="navigationSource">The <see cref="IEdmNavigationSource"/> that can be built using <see cref="ODataModelBuilder"/>.</param> /// <returns><see cref="IndexableByKeyConfiguration"/></returns> public static IndexableByKeyConfiguration HasIndexableByKey <TEntity>(this EntitySetConfiguration <TEntity> navigationSource) where TEntity : class => navigationSource?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration <IndexableByKeyConfiguration>();
/// <summary> /// <see cref="CountRestrictionsConfiguration"/> configuration /// </summary> /// <typeparam name="TEntity">The entity type of the navigation source.</typeparam> /// <param name="navigationSource">The <see cref="IEdmNavigationSource"/> that can be built using <see cref="ODataModelBuilder"/>.</param> /// <returns><see cref="CountRestrictionsConfiguration"/></returns> public static CountRestrictionsConfiguration HasCountRestrictions <TEntity>(this EntitySetConfiguration <TEntity> navigationSource) where TEntity : class => navigationSource?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration <CountRestrictionsConfiguration>();
/// <summary> /// <see cref="DeepUpdateSupportConfiguration"/> configuration /// </summary> /// <typeparam name="TEntity">The entity type of the navigation source.</typeparam> /// <param name="navigationSource">The <see cref="IEdmNavigationSource"/> that can be built using <see cref="ODataModelBuilder"/>.</param> /// <returns><see cref="DeepUpdateSupportConfiguration"/></returns> public static DeepUpdateSupportConfiguration HasDeepUpdateSupport <TEntity>(this EntitySetConfiguration <TEntity> navigationSource) where TEntity : class => navigationSource?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration <DeepUpdateSupportConfiguration>();
/// <summary> /// <see cref="FilterFunctionsConfiguration"/> configuration /// </summary> /// <typeparam name="TEntity">The entity type of the navigation source.</typeparam> /// <param name="navigationSource">The <see cref="IEdmNavigationSource"/> that can be built using <see cref="ODataModelBuilder"/>.</param> /// <returns><see cref="FilterFunctionsConfiguration"/></returns> public static FilterFunctionsConfiguration HasFilterFunctions <TEntity>(this EntitySetConfiguration <TEntity> navigationSource) where TEntity : class => navigationSource?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration <FilterFunctionsConfiguration>();
internal EntitySetConfiguration(ODataModelBuilder modelBuilder, EntitySetConfiguration configuration) : base(modelBuilder, configuration) { }