Beispiel #1
0
 public Query(IDbConnection connection, ISQLConfiguration configuration, Assembly assembly, IQueryMap queryMap)
 {
     this.connection    = connection;
     this.configuration = configuration;
     this.assembly      = assembly;
     this.queryMap      = queryMap;
 }
Beispiel #2
0
 public View(IDbConnection connection, ISQLConfiguration configuration, Assembly assembly, IViewQuery <V> viewQuery)
 {
     this.connection    = connection;
     this.configuration = configuration;
     this.assembly      = assembly;
     this.viewQuery     = viewQuery;
 }
Beispiel #3
0
 public Set(IDbConnection connection, ISQLConfiguration configuration, Assembly assembly, Contracts.IQuery <T> query, IPersist <T> persist, IModify <T> modify, IDelete <T> delete)
 {
     this.connection    = connection;
     this.configuration = configuration;
     this.assembly      = assembly;
     Query   = query;
     Persist = persist;
     Modify  = modify;
     Delete  = delete;
 }
Beispiel #4
0
 public DbContext(ISQLConfiguration configuration)
 {
     Cfg.Configuration.configuration = configuration;
     try
     {
         assembly   = Assembly.Load(configuration.AssemblyTypeName());
         connection = assembly.CreateInstance(configuration.ConnectionTypeName()) as IDbConnection;
         connection.ConnectionString = configuration.ConnectionString;
         foreach (var mapping in Cfg.Configuration.Mappings)
         {
             foreach (PropertyInfo property in GetEntities(mapping.Value.Type))
             {
                 IEntityMap entityMap;
                 Cfg.Configuration.Mappings.TryGetValue(property.PropertyType.Name, out entityMap);
                 mapping.Value.Entities.Add(property.Name, entityMap);
             }
             foreach (PropertyInfo property in GetCollections(mapping.Value.Type))
             {
                 Type       itemType = property.PropertyType.GetGenericArguments()[0];
                 IEntityMap itemEntityMap;
                 Cfg.Configuration.Mappings.TryGetValue(itemType.Name, out itemEntityMap);
                 mapping.Value.Collections.Add(property.Name, itemEntityMap);
             }
         }
         foreach (var mapping in Cfg.Configuration.Mappings)
         {
             if (!mapping.Value.Type.IsEnum)
             {
                 var query   = Activator.CreateInstance(typeof(CoreMap.Query <>).MakeGenericType(mapping.Value.Type), mapping.Value);
                 var persist = Activator.CreateInstance(typeof(Persist <>).MakeGenericType(mapping.Value.Type), mapping.Value);
                 var modify  = Activator.CreateInstance(typeof(Modify <>).MakeGenericType(mapping.Value.Type), mapping.Value);
                 var delete  = Activator.CreateInstance(typeof(Delete <>).MakeGenericType(mapping.Value.Type), mapping.Value);
                 var set     = Activator.CreateInstance(typeof(Set <>).MakeGenericType(mapping.Value.Type), connection, configuration, assembly, query, persist, modify, delete);
                 Cfg.Configuration.Sets.Add(set);
             }
         }
         foreach (var mapping in Cfg.Configuration.ViewMappings)
         {
             var viewQuery = Activator.CreateInstance(typeof(ViewQuery <>).MakeGenericType(mapping.Value.Type), mapping.Value);
             var view      = Activator.CreateInstance(typeof(View <>).MakeGenericType(mapping.Value.Type), connection, configuration, assembly, viewQuery);
             Cfg.Configuration.Views.Add(view);
         }
         foreach (var mapping in Cfg.Configuration.QueryMappings)
         {
             var queryMap = Activator.CreateInstance(typeof(Mapping.QueryMap <>).MakeGenericType(mapping.Value.Type), mapping.Value.Query);
             var query    = Activator.CreateInstance(typeof(Query <>).MakeGenericType(mapping.Value.Type), connection, configuration, assembly, queryMap);
             Cfg.Configuration.Queries.Add(query);
         }
     }
     catch
     {
         throw;
     }
 }