public void AddDynamicPropertyDictionary_ThrowsIfTypeIsNotDictionary() { // Arrange MockPropertyInfo property = new MockPropertyInfo(typeof(Int32), "Test"); Mock <StructuralTypeConfiguration> mock = new Mock <StructuralTypeConfiguration> { CallBase = true }; StructuralTypeConfiguration configuration = mock.Object; // Act & Assert Assert.ThrowsArgument(() => configuration.AddDynamicPropertyDictionary(property), "propertyInfo", string.Format("The argument must be of type '{0}'.", "IDictionary<string, object>")); }
private void MapStructuralType(StructuralTypeConfiguration structuralType) { IEnumerable <PropertyInfo> properties = ConventionsHelpers.GetProperties(structuralType, includeReadOnly: _isQueryCompositionMode); foreach (PropertyInfo property in properties) { bool isCollection; IEdmTypeConfiguration mappedType; PropertyKind propertyKind = GetPropertyType(property, out isCollection, out mappedType); if (propertyKind == PropertyKind.Primitive || propertyKind == PropertyKind.Complex || propertyKind == PropertyKind.Enum) { MapStructuralProperty(structuralType, property, propertyKind, isCollection); } else if (propertyKind == PropertyKind.Dynamic) { structuralType.AddDynamicPropertyDictionary(property); } else { // don't add this property if the user has already added it. if (structuralType.NavigationProperties.All(p => p.Name != property.Name)) { NavigationPropertyConfiguration addedNavigationProperty; if (!isCollection) { addedNavigationProperty = structuralType.AddNavigationProperty(property, EdmMultiplicity.ZeroOrOne); } else { addedNavigationProperty = structuralType.AddNavigationProperty(property, EdmMultiplicity.Many); } ContainedAttribute containedAttribute = property.GetCustomAttribute <ContainedAttribute>(); if (containedAttribute != null) { addedNavigationProperty.Contained(); } addedNavigationProperty.AddedExplicitly = false; } } } MapDerivedTypes(structuralType); }
public void HasDynamicProperties(Expression <Func <TStructuralType, IDictionary <string, object> > > propertyExpression) { PropertyInfo propertyInfo = PropertySelectorVisitor.GetSelectedProperty(propertyExpression); _configuration.AddDynamicPropertyDictionary(propertyInfo); }