Exemplo n.º 1
0
        /// <summary>Initializes a new instance of the <see cref="SQLiteDatabase" /> class.</summary>
        /// <param name="storage">The storage engine.</param>
        /// <param name="name">The name of the database.</param>
        public SQLiteDatabase(SQLiteStorage storage, string name)
            : base(storage, name)
        {
            var fields = new List <FieldProperties>
            {
                new FieldProperties {
                    Index = 0, DataType = DataType.String, Name = "type"
                },
                new FieldProperties {
                    Index = 1, DataType = DataType.String, Name = "name"
                },
                new FieldProperties {
                    Index = 2, DataType = DataType.String, Name = "tbname"
                },
                new FieldProperties {
                    Index = 3, DataType = DataType.Int64, Name = "rootpage"
                },
                new FieldProperties {
                    Index = 4, DataType = DataType.String, Name = "sql"
                }
            };

            foreach (var field in fields)
            {
                field.NameAtDatabase = field.Name;
                field.TypeAtDatabase = field.DataType;
                field.Validate();
            }

            var expected = RowLayout.CreateUntyped(name, fields.ToArray());
            var schema   = SqlStorage.QuerySchema(Name, "sqlite_master");

            SqlStorage.CheckLayout(expected, schema);
        }