public static SqlTableDefinition GetTableDefinition(this Sqlite3SchemaRow schema) { Dictionary <Sqlite3SchemaRow, SqlTableDefinition> definitionCache = schema.Database.GetProperty(SqlCacheKey, () => new Dictionary <Sqlite3SchemaRow, SqlTableDefinition>()); if (!definitionCache.TryGetValue(schema, out SqlTableDefinition definition)) { if (!SqlParser.TryParse(schema.Sql, out definition)) { definitionCache[schema] = null; } else { definitionCache[schema] = definition; } } if (definition == null) { throw new Exception(); } SqlTableDefinition def = definition; return(def); }
private void InitializeMasterTable() { // Parse table on Page 1, the sqlite_master table BTreePage rootBtree = BTreePage.Parse(_reader, 1); // Fake the schema for the sqlite_master table Sqlite3SchemaRow schemaRow = new Sqlite3SchemaRow { Database = this, Type = "table", Name = "sqlite_master", TableName = "sqlite_master", RootPage = rootBtree.Page, Sql = "CREATE TABLE sqlite_master (type TEXT, name TEXT, tbl_name TEXT, rootpage INTEGER, sql TEXT);" }; Sqlite3Table table = new Sqlite3Table(_reader, rootBtree, schemaRow); _masterTable = new Sqlite3MasterTable(this, table); }