本文整理汇总了C#中SQLitePCL.SQLiteConnection.DoesTableExist方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.DoesTableExist方法的具体用法?C# SQLiteConnection.DoesTableExist怎么用?C# SQLiteConnection.DoesTableExist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLitePCL.SQLiteConnection
的用法示例。
在下文中一共展示了SQLiteConnection.DoesTableExist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureSchemaForTable
private void EnsureSchemaForTable(string tableName, SQLiteConnection db, IDictionary<string, Column> columns)
{
EnsureDatabaseThread();
try
{
//check if database exists
if (!db.DoesTableExist(tableName))
{
Debug.WriteLine("Table doesn't exist: {0}", tableName);
db.CreateTable(tableName, columns);
Debug.WriteLine("Table {0} created with columns {1}.", tableName, string.Join<Column>("\n", columns.Values));
Debug.WriteLine("Creating index for table {0} on column 'id'", tableName);
db.CreateIndex(tableName, "id");
}
else
{
Debug.WriteLine("Table exists: {0}", tableName);
Debug.WriteLine("Querying table structure for table: {0}", tableName);
IDictionary<string, Column> tableColumns = db.GetColumnsForTable(tableName);
Debug.WriteLine("Table {0} has columns: {1}", tableName, string.Join<Column>("\n", tableColumns.Values));
IDictionary<string, Column> newColumns = this.DetermineNewColumns(tableColumns, columns);
foreach (var col in newColumns)
{
db.AddColumnForTable(tableName, col.Value);
}
}
}
catch (SQLiteException ex)
{
throw new Exception(string.Format("Error occurred during interaction with the local database: {0}", ex.Message));
}
}