示例#1
0
		public static bool TableExists(
			SQLiteConnection connection,
			string           tableName
		)
		{
			bool   boolIsTableExists = false;
			string query             = null;

			if (tableName != null)
			{
				using (connection.OpenWrapper())
				{
					query = string.Format(
						"SELECT COUNT(*) FROM [sqlite_master] m WHERE m.[type] = 'table' AND m.[name] = '{0}'",
						tableName
					);

					SqlScalarCommand command = new SqlScalarCommand(
						connection,
						query
					);

					command.Execute(100);

					if ((long)command.Result > 0L)
					{
						boolIsTableExists = true;
					}
				}
			}

			return boolIsTableExists;
		}
示例#2
0
		public static Table GetTable(SQLiteConnection connection, string name)
		{
			using (connection.OpenWrapper())
			{
				GetTableDefinitionCommand reader = new GetTableDefinitionCommand(connection, name);

				reader.Execute(100);

				TableDefinition def = reader.TableDefinition;

				return def != null
					? new Table(connection, def)
					: null;
			}
		}