Beispiel #1
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);
                    }
                }
            }
        }
Beispiel #2
0
 protected ViewModelBase()
 {
     typeContainer = TypeContainer.GetTypeContainer(GetType());
 }
Beispiel #3
0
 public ViewModelListBase(Type t, IEnumerable <ViewModelBase> objs)
 {
     this.typeContainer = TypeContainer.GetTypeContainer(t);
     this.objs          = objs;
 }