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); }
internal static string GetEntitySetName <TEntity>(this EntitySetConfiguration <TEntity> configuration) where TEntity : class { Contract.Requires(configuration != null); Contract.Ensures(!string.IsNullOrEmpty(Contract.Result <string>())); var type = typeof(NavigationSourceConfiguration <TEntity>); var field = type.GetField("_configuration", Instance | NonPublic); var innerConfig = (NavigationSourceConfiguration)field.GetValue(configuration); return(innerConfig.Name); }
/// <inheritdoc /> public override EntitySetConfiguration AddEntitySet(string name, EntityTypeConfiguration entityType) { EntitySetConfiguration entitySetConfiguration = base.AddEntitySet(name, entityType); if (_isModelBeingBuilt) { ApplyNavigationSourceConventions(entitySetConfiguration); } return(entitySetConfiguration); }
public void CtorThatTakesClrType_Sets_Property_Name() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); // Act EntitySetConfiguration entityset = new EntitySetConfiguration(builder, typeof(EntitySetConfigurationTest), "entityset"); // Assert Assert.Equal("entityset", entityset.Name); }
public void CtorThatTakesEntityTypeConfiguration_Sets_Property_EntityType() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); EntityTypeConfiguration entityType = new EntityTypeConfiguration(new ODataModelBuilder(), typeof(EntitySetConfigurationTest)); // Act EntitySetConfiguration entityset = new EntitySetConfiguration(builder, entityType, "entityset"); // Assert Assert.Equal(entityType, entityset.EntityType); }
/// <summary> /// Constructs an instance of an <see cref="EntitySetLinkBuilderAnnotation" /> from an <see cref="EntitySetConfiguration" />. /// </summary> public EntitySetLinkBuilderAnnotation(EntitySetConfiguration entitySet) { if (entitySet == null) { throw Error.ArgumentNull("entitySet"); } _entitySetName = entitySet.Name; _feedSelfLinkBuilder = entitySet.GetFeedSelfLink(); _idLinkBuilder = entitySet.GetIdLink(); _editLinkBuilder = entitySet.GetEditLink(); _readLinkBuilder = entitySet.GetReadLink(); }
public void Ctor_ThrowsArgumentNull_BindingPath() { // Assert Mock <ODataModelBuilder> builder = new Mock <ODataModelBuilder>(); ComplexTypeConfiguration complex = new ComplexTypeConfiguration(); ComplexTypeConfiguration <object> structuralType = new ComplexTypeConfiguration <object>(complex); EntitySetConfiguration navigationSource = new EntitySetConfiguration(); // Act & Assert Assert.ThrowsArgumentNull( () => new BindingPathConfiguration <object>(builder.Object, structuralType, navigationSource, bindingPath: null), "bindingPath"); }
private void ApplyEntitySetConventions(EntitySetConfiguration entitySetConfiguration) { if (!_configuredEntitySets.Contains(entitySetConfiguration)) { _configuredEntitySets.Add(entitySetConfiguration); foreach (IEntitySetConvention convention in _conventions.OfType <IEntitySetConvention>()) { if (convention != null) { convention.Apply(entitySetConfiguration, this); } } } }
public NavigationPropertyBindingConfiguration HasOptionalBinding <TTargetType>( Expression <Func <TEntityType, TTargetType> > navigationExpression, EntitySetConfiguration <TTargetType> targetSet) where TTargetType : class { if (navigationExpression == null) { throw Error.ArgumentNull("navigationExpression"); } if (targetSet == null) { throw Error.ArgumentNull("targetSet"); } return(_configuration.AddBinding(EntityType.HasOptional(navigationExpression), targetSet._configuration)); }
internal EntitySetConfiguration(ODataModelBuilder modelBuilder, EntitySetConfiguration configuration) { if (modelBuilder == null) { throw Error.ArgumentNull("modelBuilder"); } if (configuration == null) { throw Error.ArgumentNull("configuration"); } _configuration = configuration; _modelBuilder = modelBuilder; _entityType = new EntityTypeConfiguration <TEntityType>(modelBuilder, _configuration.EntityType); }
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); }
public static EntitySetComplexTypeInstanceAnnotationConfiguration <TStructuralType> HasComplexAnnotations <TEntity, TStructuralType>( this EntitySetConfiguration <TEntity> configuration, string name, IEnumerable <TStructuralType> complexValues) where TEntity : class where TStructuralType : class { Arg.NotNull(configuration, nameof(configuration)); Arg.NotNullOrEmpty(name, nameof(name)); Contract.Ensures(Contract.Result <EntitySetComplexTypeInstanceAnnotationConfiguration <TStructuralType> >() != null); var entitySetName = configuration.GetEntitySetName(); var key = Invariant($"EntitySet_{entitySetName}_{name}"); var builder = configuration.EntityType.GetModelBuilder(); var configurations = builder.GetAnnotationConfigurations(); EntitySetComplexTypeInstanceAnnotationConfiguration <TStructuralType> annotationConfig; // if the property has already been configured, return the existing configuration if (configurations.TryGet(key, out annotationConfig)) { return(annotationConfig); } var annotationType = typeof(TStructuralType); // ensure this isn't a collection; must use HasAnnotations instead if (annotationType.IsEnumerable()) { throw new InvalidOperationException(string.Format(CurrentCulture, InvalidComplexType, annotationType)); } // build an annotation for the entity property var entityType = configuration.EntityType; var qualifiedName = Invariant($"{entityType.Namespace}.{name}"); var annotationTypeConfig = builder.ComplexType <TStructuralType>(); var annotation = new InstanceAnnotation(o => complexValues, qualifiedName, annotationTypeConfig.ToEdmTypeConfiguration()) { IsComplex = true, IsCollection = true, IsNullable = true }; annotationConfig = new EntitySetComplexTypeInstanceAnnotationConfiguration <TStructuralType>(entitySetName, entityType.ToEdmTypeConfiguration(), name, annotationTypeConfig, annotation); configurations.Add(key, annotationConfig); return(annotationConfig); }
/// <summary> /// Removes the entity set from the model. /// </summary> /// <param name="name">The name of the entity set to be removed.</param> /// <returns><see>true</see> if the entity set is present in the model and <see>false</see> otherwise.</returns> public virtual bool RemoveEntitySet(string name) { if (name == null) { throw Error.ArgumentNull("name"); } if (_navigationSources.ContainsKey(name)) { EntitySetConfiguration entitySet = _navigationSources[name] as EntitySetConfiguration; if (entitySet != null) { return(_navigationSources.Remove(name)); } } return(false); }
public void GetEdmModel_DoesntCreateOperationImport_For_BoundedOperations() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); EntitySetConfiguration <Customer> customers = builder.EntitySet <Customer>("Customers"); customers.EntityType.HasKey(c => c.Id); customers.EntityType.Action("Action").Returns <bool>(); customers.EntityType.Collection.Action("CollectionAction").Returns <bool>(); customers.EntityType.Function("Function").Returns <bool>(); customers.EntityType.Collection.Function("Function").Returns <bool>(); // Act IEdmModel model = builder.GetEdmModel(); // Assert Assert.Equal(0, model.EntityContainer.OperationImports().Count()); }
/// <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); }
public NavigationPropertyBindingConfiguration HasOptionalBinding <TTargetType, TDerivedEntityType>( Expression <Func <TDerivedEntityType, TTargetType> > navigationExpression, EntitySetConfiguration <TTargetType> targetSet) where TTargetType : class where TDerivedEntityType : class, TEntityType { if (navigationExpression == null) { throw Error.ArgumentNull("navigationExpression"); } if (targetSet == null) { throw Error.ArgumentNull("targetSet"); } EntityTypeConfiguration <TDerivedEntityType> derivedEntityType = _modelBuilder.Entity <TDerivedEntityType>().DerivesFrom <TEntityType>(); return(_configuration.AddBinding(derivedEntityType.HasOptional(navigationExpression), targetSet._configuration)); }
public static void HasNavigationPropertyLink <TEntity, TValue>( this EntitySetConfiguration <TEntity> entitySet, NavigationPropertyConfiguration navigationProperty, Expression <Func <TEntity, TValue> > foreignKeyProperty, string targetEntitySetName) where TEntity : class { Arg.NotNull(entitySet, nameof(entitySet)); Arg.NotNull(navigationProperty, nameof(navigationProperty)); Arg.NotNull(foreignKeyProperty, nameof(foreignKeyProperty)); Arg.NotNullOrEmpty(targetEntitySetName, nameof(targetEntitySetName)); var foreignKeyPropertyName = foreignKeyProperty.GetPropertyName(); entitySet.HasNavigationPropertyLink( navigationProperty, (context, property) => { var entity = context.EdmObject; object value; if (!entity.TryGetPropertyValue(foreignKeyPropertyName, out value)) { return(null); } if (value == null) { return(null); } var entitySetPath = new EntitySetPathSegment(targetEntitySetName); var keyValuePath = new KeyValuePathSegment(ODataUriUtils.ConvertToUriLiteral(value, ODataVersion.V4)); var url = new Uri(context.Url.CreateODataLink(entitySetPath, keyValuePath)); return(url); }, false); }
private static EntitySetInstanceAnnotationConfiguration HasPrimitiveAnnotations <TEntity, TValue>( this EntitySetConfiguration <TEntity> configuration, string name, IEnumerable <TValue> values) where TEntity : class { Arg.NotNull(configuration, nameof(configuration)); Arg.NotNullOrEmpty(name, nameof(name)); Contract.Ensures(Contract.Result <EntitySetInstanceAnnotationConfiguration>() != null); var entitySetName = configuration.GetEntitySetName(); var key = Invariant($"EntitySet_{entitySetName}_{name}"); var builder = configuration.EntityType.GetModelBuilder(); var configurations = builder.GetAnnotationConfigurations(); EntitySetInstanceAnnotationConfiguration annotationConfig; // if the property has already been configured, return the existing configuration if (configurations.TryGet(key, out annotationConfig)) { return(annotationConfig); } var entityType = configuration.EntityType; var qualifiedName = Invariant($"{entityType.Namespace}.{name}"); var annotationType = typeof(TValue); var annotationTypeConfig = builder.GetTypeConfigurationOrNull(annotationType); var annotation = new InstanceAnnotation(o => values, qualifiedName, annotationTypeConfig) { IsCollection = true, IsNullable = annotationType.IsNullable() }; annotationConfig = new EntitySetInstanceAnnotationConfiguration(entitySetName, entityType.ToEdmTypeConfiguration(), name, annotation); configurations.Add(key, annotationConfig); return(annotationConfig); }
private static void AddExpandRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target, EntitySetConfiguration entitySetConfiguration, EdmTypeMap edmTypeMap) { EntityTypeConfiguration entityTypeConfig = entitySetConfiguration.EntityType; IEnumerable <PropertyConfiguration> nonExpandableProperties = entityTypeConfig.Properties.Where(property => property.NotExpandable); IList <IEdmNavigationProperty> properties = new List <IEdmNavigationProperty>(); foreach (PropertyConfiguration property in nonExpandableProperties) { IEdmProperty value; if (edmTypeMap.EdmProperties.TryGetValue(property.PropertyInfo, out value)) { if (value != null && value.PropertyKind == EdmPropertyKind.Navigation) { properties.Add((IEdmNavigationProperty)value); } } } if (properties.Any()) { model.SetExpandRestrictionsAnnotation(target, true, properties); } }
private static void AddNavigationBindings(EntitySetConfiguration configuration, EdmEntitySet entitySet, EntitySetLinkBuilderAnnotation linkBuilder, ODataModelBuilder builder, Dictionary <Type, IEdmType> edmTypeMap, Dictionary <string, EdmEntitySet> edmEntitySetMap) { foreach (EntityTypeConfiguration entity in builder.ThisAndBaseAndDerivedTypes(configuration.EntityType)) { foreach (NavigationPropertyConfiguration navigation in entity.NavigationProperties) { NavigationPropertyBindingConfiguration binding = configuration.FindBinding(navigation); if (binding != null) { EdmEntityType edmEntityType = edmTypeMap[entity.ClrType] as EdmEntityType; IEdmNavigationProperty edmNavigationProperty = edmEntityType.NavigationProperties().Single(np => np.Name == navigation.Name); entitySet.AddNavigationTarget(edmNavigationProperty, edmEntitySetMap[binding.EntitySet.Name]); NavigationLinkBuilder linkBuilderFunc = configuration.GetNavigationPropertyLink(navigation); if (linkBuilderFunc != null) { linkBuilder.AddNavigationPropertyLinkBuilder(edmNavigationProperty, linkBuilderFunc); } } } } }
private static void AddSortRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target, EntitySetConfiguration entitySetConfiguration, EdmTypeMap edmTypeMap) { EntityTypeConfiguration entityTypeConfig = entitySetConfiguration.EntityType; IEnumerable <PropertyConfiguration> nonSortableProperties = entityTypeConfig.Properties.Where(property => property.Unsortable); IList <IEdmProperty> properties = new List <IEdmProperty>(); foreach (PropertyConfiguration property in nonSortableProperties) { IEdmProperty value; if (edmTypeMap.EdmProperties.TryGetValue(property.PropertyInfo, out value)) { if (value != null) { properties.Add(value); } } } if (properties.Any()) { model.SetSortRestrictionsAnnotation(target, true, null, null, properties); } }
public NavigationSourceLinkBuilderAnnotationTest() { _modelBuilder = ODataModelBuilderMocks.GetModelBuilderMock <ODataModelBuilder>(); _entitySet = _modelBuilder.AddEntitySet("Customers", _modelBuilder.AddEntityType(typeof(Customer))); }
/// <summary> /// Binds the given navigation property to the target entity set. /// </summary> /// <param name="navigationConfiguration">The navigation property.</param> /// <param name="targetEntitySet">The target entity set.</param> /// <returns>The <see cref="NavigationPropertyBindingConfiguration"/> so that it can be further configured.</returns> public virtual NavigationPropertyBindingConfiguration AddBinding(NavigationPropertyConfiguration navigationConfiguration, EntitySetConfiguration targetEntitySet) { if (navigationConfiguration == null) { throw Error.ArgumentNull("navigationConfiguration"); } if (targetEntitySet == null) { throw Error.ArgumentNull("targetEntitySet"); } EntityTypeConfiguration declaringEntityType = navigationConfiguration.DeclaringEntityType; if (!(declaringEntityType.IsAssignableFrom(EntityType) || EntityType.IsAssignableFrom(declaringEntityType))) { throw Error.Argument("navigationConfiguration", SRResources.NavigationPropertyNotInHierarchy, declaringEntityType.FullName, EntityType.FullName, Name); } NavigationPropertyBindingConfiguration navigationPropertyBinding = null; if (_entitySetBindings.ContainsKey(navigationConfiguration)) { navigationPropertyBinding = _entitySetBindings[navigationConfiguration]; if (navigationPropertyBinding.EntitySet != targetEntitySet) { throw Error.NotSupported(SRResources.RebindingNotSupported); } } else { navigationPropertyBinding = new NavigationPropertyBindingConfiguration(navigationConfiguration, targetEntitySet); _entitySetBindings[navigationConfiguration] = navigationPropertyBinding; } return(navigationPropertyBinding); }
private static void AddOptimisticConcurrencyAnnotation(this EdmModel model, IEdmEntitySet target, EntitySetConfiguration entitySetConfiguration, EdmTypeMap edmTypeMap) { EntityTypeConfiguration entityTypeConfig = entitySetConfiguration.EntityType; IEnumerable<StructuralPropertyConfiguration> concurrencyPropertyies = entityTypeConfig.Properties.OfType<StructuralPropertyConfiguration>().Where(property => property.ConcurrencyToken); IList<IEdmStructuralProperty> edmProperties = new List<IEdmStructuralProperty>(); foreach (StructuralPropertyConfiguration property in concurrencyPropertyies) { IEdmProperty value; if (edmTypeMap.EdmProperties.TryGetValue(property.PropertyInfo, out value)) { var item = value as IEdmStructuralProperty; if (item != null) { edmProperties.Add(item); } } } if (edmProperties.Any()) { model.SetOptimisticConcurrencyAnnotation(target, edmProperties); } }
public EntitySetConfigurationTest() { _builder = new ODataModelBuilder(); _entityset = new EntitySetConfiguration(_builder, typeof(EntitySetConfigurationTest), "entityset"); }
private static void AddExpandRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target, EntitySetConfiguration entitySetConfiguration, EdmTypeMap edmTypeMap) { EntityTypeConfiguration entityTypeConfig = entitySetConfiguration.EntityType; IEnumerable<PropertyConfiguration> nonExpandableProperties = entityTypeConfig.Properties.Where(property => property.NotExpandable); IList<IEdmNavigationProperty> properties = new List<IEdmNavigationProperty>(); foreach (PropertyConfiguration property in nonExpandableProperties) { IEdmProperty value; if (edmTypeMap.EdmProperties.TryGetValue(property.PropertyInfo, out value)) { if (value != null && value.PropertyKind == EdmPropertyKind.Navigation) { properties.Add((IEdmNavigationProperty)value); } } } if (properties.Any()) { model.SetExpandRestrictionsAnnotation(target, true, properties); } }
public static EntitySetInstanceAnnotationConfiguration HasAnnotation <TEntity>(this EntitySetConfiguration <TEntity> configuration, string name, string value) where TEntity : class => configuration.HasPrimitiveAnnotation(name, value);
public void CtorThatTakesClrType_Sets_Property_EntityType() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); // Act EntitySetConfiguration entityset = new EntitySetConfiguration(builder, typeof(EntitySetConfigurationTest), "entityset"); // Assert Assert.NotNull(entityset.EntityType); Assert.Equal(typeof(EntitySetConfigurationTest), entityset.EntityType.ClrType); }
private static EdmEntitySet AddEntitySet(this EdmEntityContainer container, EntitySetConfiguration entitySet, IDictionary <Type, IEdmType> edmTypeMap) { return(container.AddEntitySet(entitySet.Name, (IEdmEntityType)edmTypeMap[entitySet.EntityType.ClrType])); }
internal EntitySetConfiguration(ODataModelBuilder modelBuilder, EntitySetConfiguration configuration) : base(modelBuilder, configuration) { }
private static void AddNavigationBindings(EntitySetConfiguration configuration, EdmEntitySet entitySet, EntitySetLinkBuilderAnnotation linkBuilder, ODataModelBuilder builder, Dictionary<Type, IEdmType> edmTypeMap, Dictionary<string, EdmEntitySet> edmEntitySetMap) { foreach (EntityTypeConfiguration entity in builder.ThisAndBaseAndDerivedTypes(configuration.EntityType)) { foreach (NavigationPropertyConfiguration navigation in entity.NavigationProperties) { NavigationPropertyBindingConfiguration binding = configuration.FindBinding(navigation); if (binding != null) { EdmEntityType edmEntityType = edmTypeMap[entity.ClrType] as EdmEntityType; IEdmNavigationProperty edmNavigationProperty = edmEntityType.NavigationProperties().Single(np => np.Name == navigation.Name); entitySet.AddNavigationTarget(edmNavigationProperty, edmEntitySetMap[binding.EntitySet.Name]); NavigationLinkBuilder linkBuilderFunc = configuration.GetNavigationPropertyLink(navigation); if (linkBuilderFunc != null) { linkBuilder.AddNavigationPropertyLinkBuilder(edmNavigationProperty, linkBuilderFunc); } } } } }
private static EdmEntitySet AddEntitySet(this EdmEntityContainer container, EntitySetConfiguration entitySet, IDictionary<Type, IEdmType> edmTypeMap) { return container.AddEntitySet(entitySet.Name, (IEdmEntityType)edmTypeMap[entitySet.EntityType.ClrType]); }
/// <summary> /// Binds the given navigation property to the target entity set. /// </summary> /// <param name="navigationConfiguration">The navigation property.</param> /// <param name="targetEntitySet">The target entity set.</param> /// <returns>The <see cref="NavigationPropertyBindingConfiguration"/> so that it can be further configured.</returns> public virtual NavigationPropertyBindingConfiguration AddBinding(NavigationPropertyConfiguration navigationConfiguration, EntitySetConfiguration targetEntitySet) { if (navigationConfiguration == null) { throw Error.ArgumentNull("navigationConfiguration"); } if (targetEntitySet == null) { throw Error.ArgumentNull("targetEntitySet"); } EntityTypeConfiguration declaringEntityType = navigationConfiguration.DeclaringEntityType; if (!(declaringEntityType.IsAssignableFrom(EntityType) || EntityType.IsAssignableFrom(declaringEntityType))) { throw Error.Argument("navigationConfiguration", SRResources.NavigationPropertyNotInHierarchy, declaringEntityType.FullName, EntityType.FullName, Name); } NavigationPropertyBindingConfiguration navigationPropertyBinding = null; if (_entitySetBindings.ContainsKey(navigationConfiguration)) { navigationPropertyBinding = _entitySetBindings[navigationConfiguration]; if (navigationPropertyBinding.EntitySet != targetEntitySet) { throw Error.NotSupported(SRResources.RebindingNotSupported); } } else { navigationPropertyBinding = new NavigationPropertyBindingConfiguration(navigationConfiguration, targetEntitySet); _entitySetBindings[navigationConfiguration] = navigationPropertyBinding; } return navigationPropertyBinding; }
private static void AddNavigationRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target, EntitySetConfiguration entitySetConfiguration, EdmTypeMap edmTypeMap) { EntityTypeConfiguration entityTypeConfig = entitySetConfiguration.EntityType; IEnumerable<PropertyConfiguration> notNavigableProperties = entityTypeConfig.Properties.Where(property => property.NotNavigable); IList<Tuple<IEdmNavigationProperty, CapabilitiesNavigationType>> properties = new List<Tuple<IEdmNavigationProperty, CapabilitiesNavigationType>>(); foreach (PropertyConfiguration property in notNavigableProperties) { IEdmProperty value; if (edmTypeMap.EdmProperties.TryGetValue(property.PropertyInfo, out value)) { if (value != null && value.PropertyKind == EdmPropertyKind.Navigation) { properties.Add(new Tuple<IEdmNavigationProperty, CapabilitiesNavigationType>( (IEdmNavigationProperty)value, CapabilitiesNavigationType.Recursive)); } } } if (properties.Any()) { model.SetNavigationRestrictionsAnnotation(target, CapabilitiesNavigationType.Recursive, properties); } }
public NavigationSourceLinkBuilderAnnotationTest() { _modelBuilder = ODataModelBuilderMocks.GetModelBuilderMock<ODataModelBuilder>(); _entitySet = _modelBuilder.AddEntitySet("Customers", _modelBuilder.AddEntityType(typeof(Customer))); }
public static EntitySetInstanceAnnotationConfiguration HasAnnotations <TEntity>(this EntitySetConfiguration <TEntity> configuration, string name, IEnumerable <string> values) where TEntity : class => configuration.HasPrimitiveAnnotations(name, values);
public EntitySetLinkBuilderAnnotationTest() { _modelBuilder = new ODataModelBuilder(); _entitySet = _modelBuilder.AddEntitySet("Customers", _modelBuilder.AddEntity(typeof(Customer))); }
public static ODataModelBuilder GetModelBuilder <TStructuralType>(this EntitySetConfiguration <TStructuralType> configuration) where TStructuralType : class { Arg.NotNull(configuration, nameof(configuration)); Contract.Ensures(Contract.Result <ODataModelBuilder>() != null); return(configuration.EntityType.GetModelBuilder()); }
private static void AddSortRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target, EntitySetConfiguration entitySetConfiguration, EdmTypeMap edmTypeMap) { EntityTypeConfiguration entityTypeConfig = entitySetConfiguration.EntityType; IEnumerable<PropertyConfiguration> nonSortableProperties = entityTypeConfig.Properties.Where(property => property.Unsortable); IList<IEdmProperty> properties = new List<IEdmProperty>(); foreach (PropertyConfiguration property in nonSortableProperties) { IEdmProperty value; if (edmTypeMap.EdmProperties.TryGetValue(property.PropertyInfo, out value)) { if (value != null) { properties.Add(value); } } } if (properties.Any()) { model.SetSortRestrictionsAnnotation(target, true, null, null, properties); } }