Skip to content

Instantly share code, notes, and snippets.

@DaniCCardenas
Last active April 30, 2018 09:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save DaniCCardenas/e5730a59f98b58eb2010cfe3618bdd59 to your computer and use it in GitHub Desktop.
public static string GetCreateTableQuery<T>(IEnumerable<T> list, string tableName)
{
Type type = typeof(T);
var properties = type.GetProperties();
var query = new StringBuilder();
query.Append($"CREATE TABLE {tableName} (");
foreach (PropertyInfo info in properties)
{
query.Append($"{info.Name} nvarchar(max),");
}
query.Append(");");
return query.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment