public void GetClrType_returns_CLR_type_annotation_for_ComplexType() { var complexType = new ComplexType("C", "N", DataSpace.CSpace); Assert.Null(((EdmType)complexType).GetClrType()); complexType.GetMetadataProperties().SetClrType(typeof(Random)); Assert.Same(typeof(Random), ((EdmType)complexType).GetClrType()); }
public void Should_be_able_to_get_and_set_clr_type() { var complexType = new ComplexType("C"); Assert.Null(complexType.GetClrType()); var type = typeof(object); complexType.GetMetadataProperties().SetClrType(type); Assert.Equal(typeof(object), complexType.GetClrType()); }
public void GetComplexParameterBindings_should_return_all_complex_parameter_bindings_for_type() { var databaseMapping = new DbDatabaseMapping() .Initialize( new EdmModel(DataSpace.CSpace), new EdmModel(DataSpace.SSpace)); var entityType = new EntityType("E", "N", DataSpace.CSpace); var entitySet = databaseMapping.Model.AddEntitySet("ES", entityType); var entitySetMapping = databaseMapping.AddEntitySetMapping(entitySet); var complexType1 = new ComplexType(); complexType1.GetMetadataProperties().SetClrType(typeof(string)); var complexType2 = new ComplexType(); complexType2.GetMetadataProperties().SetClrType(typeof(object)); var storageModificationFunctionMapping = new ModificationFunctionMapping( entitySet, entityType, new EdmFunction("F", "N", DataSpace.SSpace), new[] { new ModificationFunctionParameterBinding( new FunctionParameter(), new ModificationFunctionMemberPath( new EdmMember[] { EdmProperty.CreateComplex("C1", complexType1), EdmProperty.CreateComplex("C2", complexType2), new EdmProperty("M") }, null), true ) }, null, null); entitySetMapping.AddModificationFunctionMapping( new EntityTypeModificationFunctionMapping( entityType, storageModificationFunctionMapping, storageModificationFunctionMapping, storageModificationFunctionMapping)); Assert.Equal(3, databaseMapping.GetComplexParameterBindings(typeof(string)).Count()); Assert.Equal(3, databaseMapping.GetComplexParameterBindings(typeof(object)).Count()); }
public void GetComplexPropertyMappings_should_return_all_complex_property_mappings_for_type() { var databaseMapping = new DbDatabaseMapping() .Initialize(new EdmModel(DataSpace.CSpace), new EdmModel(DataSpace.SSpace)); var entitySet = new EntitySet { Name = "ES" }; var entitySetMapping = databaseMapping.AddEntitySetMapping(entitySet); var entityTypeMapping = new EntityTypeMapping(null); entitySetMapping.AddTypeMapping(entityTypeMapping); var entityTypeMappingFragment = new MappingFragment(entitySet, entityTypeMapping, false); entityTypeMapping.AddFragment(entityTypeMappingFragment); var complexType = new ComplexType("C"); var propertyMapping1 = new ColumnMappingBuilder( new EdmProperty("C", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace })), new[] { EdmProperty.CreateComplex("P1", complexType), EdmProperty.CreatePrimitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)) }); var type = typeof(object); complexType.GetMetadataProperties().SetClrType(type); entityTypeMappingFragment.AddColumnMapping(propertyMapping1); var propertyMapping2 = new ColumnMappingBuilder( new EdmProperty("C", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace })), new List<EdmProperty> { EdmProperty.CreateComplex("P3", complexType), EdmProperty.CreatePrimitive( "P2", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)), }); entityTypeMappingFragment.AddColumnMapping(propertyMapping2); Assert.Equal(2, databaseMapping.GetComplexPropertyMappings(typeof(object)).Count()); }
internal virtual void Configure(ComplexType complexType) { Configure(complexType.Name, complexType.Properties, complexType.GetMetadataProperties()); }