Beispiel #1
0
 public void Apply(IDbModelBuilder modelBuilder)
 {
     if (PersistenceConfigurator.MappingsAssembly != null)
     {
         MapEntitiesFromMappingConfigurations(modelBuilder);
     }
     if (PersistenceConfigurator.EntititesAssembly != null)
     {
         MapEntitiesByDefaultConventions(modelBuilder);
     }
 }
Beispiel #2
0
        private void MapEntitiesFromMappingConfigurations(IDbModelBuilder modelBuilder)
        {
            List <Type> list =
                (from type in
                 PersistenceConfigurator.MappingsAssembly.GetTypes()
                 .Where(p => p.Namespace != "SIGCOMT.Domain.Core")
                 where
                 type.BaseType != null &&
                 (type.BaseType.IsGenericType && (type.BaseType.GetGenericTypeDefinition() == typeof(EntityTypeConfiguration <>)))
                 select type).ToList <Type>();

            foreach (Type type in list)
            {
                modelBuilder.AddConfiguration(type);
                Type baseType = type.BaseType;
                _alreadyMappedEntities.Add(baseType.GetGenericArguments()[0]);
            }
        }
Beispiel #3
0
        private void MapEntitiesByDefaultConventions(IDbModelBuilder modelBuilder)
        {
            List <Type> list =
                (from type in
                 PersistenceConfigurator.EntititesAssembly.GetExportedTypes()
                 .Where(p => p.Namespace != "SIGCOMT.Domain.Core")
                 where (type.BaseType != null &&
                        (type.BaseType.IsGenericType &&
                         (type.BaseType.GetGenericTypeDefinition() == typeof(Entity <>) ||
                          type.BaseType.GetGenericTypeDefinition() == typeof(EntityWithTypedId <>) ||
                          type.BaseType.GetGenericTypeDefinition() == typeof(EntityExtension <>) ||
                          type.BaseType.GetGenericTypeDefinition() == typeof(EntityBase))))
                 select type).ToList <Type>();

            foreach (Type type in list)
            {
                if (!_alreadyMappedEntities.Contains(type))
                {
                    modelBuilder.AddEntity(type);
                }
            }
        }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EFDataContext" /> class.
 /// </summary>
 /// <param name="connection">The connection.</param>
 /// <param name="dbModelBuilder">The database model builder.</param>
 public EFDataContext(IDbConnection connection,
                      IDbModelBuilder dbModelBuilder) : base(connection.ConnectionString, dbModelBuilder.GetCompiled(connection))
 {
     //_dbModelBuilder = dbModelBuilder;
 }