I have a situation where I want to import data from an external source which I don't know the schema at design time, this comes into my function as a DataSet.
I want to import a table from the dataset into SQLite, ideally I'd like to write something like this:
using (var connection = new SQLiteConnection("Data Source=temp.db")) {
var command = connection.CreateCommand();
command.CommandText = @"CREATE TABLE tempTable AS SELECT * FROM @tvp";
SQLiteParameter param = command.Parameters.AddWithValue("tvp", importedData.Tables[0]);
command.ExecuteNonQuery();
}
The code above throws an error saying there's a syntax error near @tvp which I wasn't able to get rid of, does SQLite not support the table valued parameter or am I missing some syntax? Is there a practical way to accomplish this?