mercredi 31 décembre 2014

Drop SQLite tables using list of tables names

I am trying to drop a collection of tables by using tables names in the list and then get the type of each string and drop it :



List<string> models = new List<string> { "WebBrowser", "Notebook", "Members"};

foreach (string mod in models)
{

Type type = Type.GetType(mod));
using (var dbConn = new SQLiteConnection(app.DBPath))
{
dbConn.RunInTransaction(() =>
{
dbConn.DropTable<type>();
//dbConn.DropTable<WebBrowser>();
dbConn.Dispose();
dbConn.Close();
});
}
}


Problem : I can't drop table using this way, DropTable need the name of class (e.g WebBrowser ) and I don't want to drop each table alone (i.e dbConn.DropTable< WebBrowser >();) since I have more than 50 tables to drop.


Aucun commentaire:

Enregistrer un commentaire