Example #1
0
 public AmlRepositoryGraphDb(SqliteConnection conn,
                             SqlitePropertiesAndCommands <Party> partySql,
                             SqlitePropertiesAndCommands <Account> accountSql,
                             SqlitePropertiesAndCommands <Transaction> transactionSql) : base(conn, typeof(AmlRepositoryQuery))
 {
     this.partySql       = partySql;
     this.accountSql     = accountSql;
     this.transactionSql = transactionSql;
 }
Example #2
0
        public A4ARepository(String connectionString)
        {
            L.Trace("Initializing types in assembly");

            foreach (var type in A4ATypes)
            {
                tables[type] =
                    new SqlTableWithPrimaryKey(new SqlitePropertiesAndCommands(TypeContainer.GetTypeContainer(type)));
            }

            primaryKeyAndTypeManager.AddPrimaryKeyPrefixAndEnum(typeof(A4AExpert), "E", A4APartyType.Expert)
            .AddPrimaryKeyPrefixAndEnum(typeof(A4AUser), "U", A4APartyType.User)
            .AddPrimaryKeyPrefixAndEnum(typeof(A4AAdministrator), "A", A4APartyType.Admin);

            GetTable <A4AExpert>().SetUniqueIdPrefix("EX");
            GetTable <A4AUser>().SetUniqueIdPrefix("US");
            GetTable <A4AAdministrator>().SetUniqueIdPrefix("AD");
            GetTable <A4AMessage>().SetUniqueIdPrefix("MX");
            GetTable <A4AEmailRecord>().SetUniqueIdPrefix("EM");


            aggregateMessage = new SqlitePropertiesAndCommands(TypeContainer.GetTypeContainer(typeof(AggregateMessage)));

            conn = new SqlConnection(connectionString);

            L.Trace($"Initializing Sql - connectionString is {connectionString}");

            using (var connection = conn.Connection())
            {
                foreach (var c in tables.Keys)
                {
                    tables[c].PropertiesAndCommands
                    .VerifyForeignKeysFromOtherTables(tables.Values.Select(x => x.PropertiesAndCommands));

                    if (tables[c].TableExists(connection) == false)
                    {
                        tables[c].CreateTable(connection);
                    }
                    else
                    {
                        tables[c].UpdateTableStructure(connection);
                    }
                }
            }
        }