I am trying to use petapoco to generate a table at runtime with a table name I specify but also use that table name to specify the TableName attribute of the model class.
The model would look something like this:
namespace Models
{
public class Row
{
public string column1;
public string column2;
}
}
and the create statement would use the db.Execute function on a string defined in code with the table name being replaced by a dynamic value:
string sql = @"CREATE TABLE [StageGeneric](
[Id] [int] IDENTITY(1,1) NOT NULL,
[column1] [varchar](50) NULL,
[column2] [varchar](50) NULL,".Replace("StageGeneric", tableName);
So my question is, is the functionality built into petapoco to set the TableName attribute programmatically? Or would I have to do something like generate the model class at runtime?
Resolved. I couldn't find exactly what I wanted. But I did find a work around. Creating the model class at runtime: C# How to set StructLayoutAttribute.Pack via Reflection?