public void CreateTable(TableDescriptor table)
 {
     try
     {
         OpenConnection();
         QueryCreator.Validate(table, true);
         var createQuery = QueryCreator.CreateTableQuery<string>(table);
         var cmd = new SQLiteCommand(createQuery, _connection);
         cmd.ExecuteNonQuery();
     }
     catch(Exception)
     {
         CloseConnection();
     }
 }
 public bool Verify(TableDescriptor tableDescriptor, bool throwOnError = false)
 {
     return true;
 }
 public void CreateTable(TableDescriptor table)
 {
     throw new System.NotImplementedException();
 }
 private TableDescriptor CreateUsers(DatabaseService ds)
 {
     var kd = new KeyDescriptor("Id");
     var td = new TableDescriptor("Users");
     td.AddField("Id", ds.GetFieldDescriptor("guid"));
     td.AddField("Username", ds.GetFieldDescriptor("username"));
     td.AddField("Password", ds.GetFieldDescriptor("password"));
     td.AddField("Nickname", ds.GetFieldDescriptor("nickname"));
     td.SetPrimaryKey(kd);
     kd = new KeyDescriptor("Username");
     kd.SetType(true, false, true);
     td.AddKey(kd);
     return td;
 }
 private TableDescriptor CreateRoles(DatabaseService ds)
 {
     var kd = new KeyDescriptor("Id");
     var td = new TableDescriptor("Roles");
     td.AddField("Id", ds.GetFieldDescriptor("guid"));
     td.AddField("UsersId", ds.GetFieldDescriptor("guid"));
     td.AddField("Role", ds.GetFieldDescriptor("role"));
     td.SetPrimaryKey(kd);
     kd = new KeyDescriptor("UsersId");
     kd.SetType(true, false, true);
     td.AddKey(kd);
     return td;
 }
 private TableDescriptor CreateQueue(DatabaseService ds)
 {
     var kd = new KeyDescriptor("Id");
     var td = new TableDescriptor("Queue");
     td.AddField("Id", ds.GetFieldDescriptor("guid"));
     td.AddField("UsersId", ds.GetFieldDescriptor("guid"));
     td.AddField("Message", ds.GetFieldDescriptor("message"));
     td.AddField("MessageType", ds.GetFieldDescriptor("messagetype"));
     td.AddField("Destination", ds.GetFieldDescriptor("destination"));
     td.SetPrimaryKey(kd);
     kd = new KeyDescriptor("UsersId");
     kd.SetType(true, false, true);
     td.AddKey(kd);
     kd = new KeyDescriptor("Destination");
     kd.SetType(false, false, true);
     td.AddKey(kd);
     kd = new KeyDescriptor("MessageType");
     kd.SetType(false, false, true);
     td.AddKey(kd);
     return td;
 }
 private static void SetupFkFromUsersToRoles(TableDescriptor roles, TableDescriptor users)
 {
     var fk = new ForeignKeyDescriptor(roles);
     fk.SetFields("Id", "UsersId");
     users.AddForeignKey(fk);
 }
Beispiel #8
0
 public QueryTable(TableDescriptor tableDescriptor, string alias)
     : this(tableDescriptor.FullName, alias)
 {
     _tableDescriptor = tableDescriptor;
 }
 public void AddForeignKey(TableDescriptor descriptor,
     ForeignKeyMultplicity multplicity = ForeignKeyMultplicity.OneToOne)
 {
     AddForeignKey(new ForeignKeyDescriptor(descriptor, multplicity));
 }
 public void RegisterTable(TableDescriptor tableDescriptor)
 {
     var tbname = tableDescriptor.FullName.ToLowerInvariant();
     tableDescriptor.Parent = this;
     if (!_tableDescriptors.ContainsKey(tbname)) _tableDescriptors.Add(tbname, tableDescriptor);
 }
 public bool Verify(TableDescriptor tableDescriptor, bool throwOnError = false)
 {
     return QueryCreator.Validate(tableDescriptor, throwOnError);
 }