public void Can_get_and_set_clr_type_annotation() { var entityType = new EntityType("E", "N", DataSpace.CSpace); Assert.Null(entityType.GetClrType()); var type = typeof(object); entityType.Annotations.SetClrType(type); Assert.Equal(typeof(object), entityType.GetClrType()); }
public void Generate(EntityType entityType, DbDatabaseMapping databaseMapping) { DebugCheck.NotNull(entityType); DebugCheck.NotNull(databaseMapping); var entitySet = databaseMapping.Model.GetEntitySet(entityType); var entitySetMapping = databaseMapping.GetEntitySetMapping(entitySet) ?? databaseMapping.AddEntitySetMapping(entitySet); var entityTypeMapping = entitySetMapping.EntityTypeMappings.FirstOrDefault( m => m.EntityTypes.Contains(entitySet.ElementType)) ?? entitySetMapping.EntityTypeMappings.FirstOrDefault(); var table = entityTypeMapping != null ? entityTypeMapping.MappingFragments.First().Table : databaseMapping.Database.AddTable(entityType.GetRootType().Name); entityTypeMapping = new EntityTypeMapping(null); var entityTypeMappingFragment = new MappingFragment(databaseMapping.Database.GetEntitySet(table), entityTypeMapping, false); entityTypeMapping.AddType(entityType); entityTypeMapping.AddFragment(entityTypeMappingFragment); entityTypeMapping.SetClrType(entityType.GetClrType()); entitySetMapping.AddTypeMapping(entityTypeMapping); new PropertyMappingGenerator(_providerManifest) .Generate( entityType, entityType.Properties, entitySetMapping, entityTypeMappingFragment, new List<EdmProperty>(), false); }
protected static StorageEntityTypeMapping GetEntityTypeMappingInHierarchy( DbDatabaseMapping databaseMapping, EntityType entityType) { DebugCheck.NotNull(databaseMapping); DebugCheck.NotNull(entityType); var entityTypeMapping = databaseMapping.GetEntityTypeMapping(entityType); if (entityTypeMapping == null) { var entitySetMapping = databaseMapping.GetEntitySetMapping(databaseMapping.Model.GetEntitySet(entityType)); if (entitySetMapping != null) { entityTypeMapping = entitySetMapping .EntityTypeMappings .First( etm => entityType.DeclaredProperties.All( dp => etm.MappingFragments.First() .ColumnMappings.Select(pm => pm.PropertyPath.First()).Contains(dp))); } } if (entityTypeMapping == null) { throw Error.UnmappedAbstractType(entityType.GetClrType()); } return entityTypeMapping; }
internal void Configure( EntityType entityType, DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest) { DebugCheck.NotNull(entityType); DebugCheck.NotNull(databaseMapping); DebugCheck.NotNull(providerManifest); var entityTypeMapping = databaseMapping.GetEntityTypeMapping(entityType.GetClrType()); if (entityTypeMapping != null) { VerifyAllCSpacePropertiesAreMapped( databaseMapping.GetEntityTypeMappings(entityType).ToList(), entityTypeMapping.EntityType.DeclaredProperties, new List<EdmProperty>()); } ConfigurePropertyMappings(databaseMapping, entityType, providerManifest); ConfigureAssociationMappings(databaseMapping, entityType, providerManifest); ConfigureDependentKeys(databaseMapping, providerManifest); ConfigureModificationFunctions(databaseMapping, entityType, providerManifest); }
internal static void ConfigureUnconfiguredType( DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest, EntityType entityType) { var c = new EntityMappingConfiguration(); var entityTypeMapping = databaseMapping.GetEntityTypeMapping(entityType.GetClrType()); c.Configure(databaseMapping, providerManifest, entityType, ref entityTypeMapping, false, 0, 1); }
internal static void ConfigureUnconfiguredType( DbDatabaseMapping databaseMapping, ICollection<EntitySet> entitySets, DbProviderManifest providerManifest, EntityType entityType, IDictionary<string, object> commonAnnotations) { var c = new EntityMappingConfiguration(); var entityTypeMapping = databaseMapping.GetEntityTypeMapping(entityType.GetClrType()); c.Configure(databaseMapping, entitySets, providerManifest, entityType, ref entityTypeMapping, false, 0, 1, commonAnnotations); }