Search code examples
c#dapper

Create table from object type


I'm trying to figure out how I can create an empty table from an object type. The type is quite simple (only primitive type properties); there's something ready to use?

Do I need to make to write my own "CREATE TABLE" query using some properties reflection?

I'm working on a project that reads data from a FirebirdSQL database and writes some of that tables in a Sqlite database, using Dapper.

Any suggestions are appreciated.


Solution

  • As Marc stated, Dapper isn't going to do that for you, but have a look at my answer here (ADO.NET distinct data bases) and simply adapt one of the command properties to construct a CREATE TABLE statement and it will leverage reflection. It should be pretty straight forward with that much of a head start.

    I'd create an example, but I'm answering this from my phone.