示例#1
0
文件: CsvDb.cs 项目: Diogny/CsvDb
        /// <summary>
        /// Re load the schema structure of the database from disk
        /// </summary>
        /// <returns>true if loaded successfully</returns>
        public bool Load()
        {
            try
            {
                var reader = new io.BinaryReader(io.File.OpenRead(SchemaFilePath));
                Schema = DbSchemaConfig.Load(reader);
                reader.Dispose();

                //link
                foreach (var table in Tables)
                {
                    table.Database = this;
                    foreach (var column in table.Columns)
                    {
                        //update
                        if (!column.Indexed)
                        {
                            column.NodePages = 0;
                            column.ItemPages = 0;
                        }
                        column.Table = table;
                    }
                }
                ;
                SaveKeyIndexedKeyOffsets();

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }