Ejemplo n.º 1
0
 private static void CreatePrimaryKeys(IEnumerable <Table> tables, DapperDatabase dapperDatabase, IDbConnection connection)
 {
     foreach (var table in tables)
     {
         ExecuteScript(dapperDatabase.GenerateScriptPrimaryKey(table), connection);
     }
 }
Ejemplo n.º 2
0
 private static void CreateForeignKeys(IEnumerable <Table> tables, DapperDatabase dapperDatabase, IDbConnection connection)
 {
     foreach (var table in tables)
     {
         foreach (var script in dapperDatabase.GenerateScriptsForeignKeys(table))
         {
             ExecuteScript(script, connection);
         }
     }
 }
Ejemplo n.º 3
0
        public static Task CreateDatabase(this IDbConnection connection,
                                          Assembly assemblyOfModels,
                                          IEnumerable <RelationDataType> relationsDataType,
                                          DapperDatabase dapperDatabase)
        {
            return(Task.Factory.StartNew(() =>
            {
                var tablesTypes = assemblyOfModels.GetTypes()
                                  .Where(a => a.GetCustomAttributes(true).OfType <TableAttribute>().Any());

                DapperField.SetarRelationDataTypes(relationsDataType);

                var dapperTables = (from tableType in tablesTypes
                                    select DapperTable.Criar(tableType)).ToList();

                CreateSequences(dapperTables, dapperDatabase, connection);
                CreateTables(dapperTables, dapperDatabase, connection);
                CreatePrimaryKeys(dapperTables, dapperDatabase, connection);
                CreateForeignKeys(dapperTables, dapperDatabase, connection);
            }));
        }