Create different TableS dynamically with only one class definition #165

Perret opened this Issue Feb 18, 2013 · 4 comments


3 participants

Perret commented Feb 18, 2013


Is there any way to create different tables dynamically (i.e. without hardcoding many class definitions) based on one class (cause I don't think that new classes can be generated on fly), or at least same definition but with a different name?


EDIT: and without using an command "CREATE TABLE " etc... i'm not sure if someone has suceeded to create Table suing some reflection tricks.


praeclarum commented Feb 21, 2013

I have been tempted to add explicit table names, so you could do something like:

db.CreateTable ("AlphaThings");
db.CreateTable ("BetaThings");
db.CreateTable ("GammaThings");


Would that help?

Perret commented Feb 22, 2013

Sometimes the table has to be created following a user definition, i.e the columns can't be hardcoded either.
Well maybe there is no solution and I'm stuck with old fashion Strings =/.

Maybe a first trick could be to have a decent syntax for creating different table based on the same schema but with different name using something like:
But then I guess it would create bunches of problem for the other methods...
i.e. insert(MyClassDefinitionObject); //(but which table?)


louy commented Mar 28, 2013

Did you try Inheritance?

public class MyClass
        [PrimaryKey, AutoIncrement]
        public int Id { get; set; }
        public string Name { get; set; }
        // ...
public class MyClass2 : MyClass

Perret commented Apr 1, 2013

Yes but can you generate new inherited classes without hardcoding?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment