RegisterType
RegisterType method is used to create an empty object storage for a specific type. Useful in the database creation scripts.
Sometimes there are needs to speed up type registration process. In these occasions inmemory;persist; options may come handy.
//Establish
connection
DB db = new DB("server=(local);password=pwd;options=inmemory,persist;");
//Create the
database
db.DeleteDatabase(DBName, true);
db.CreateDatabase(DBName);
//Open existing
database
db.OpenDatabase(DBName);
//Register user
types
db.RegisterType(typeof(A1));
db.RegisterType(typeof(A2));
db.RegisterType(typeof(A3));
db.RegisterType(typeof(A4));
db.RegisterType(typeof(A5));
db.RegisterType(typeof(A6));
db.RegisterType(typeof(A7));
//...
db.Close();
//Open existing
database
db = new DB("server=(local);password=pwd;options=;");
db.OpenDatabase(DBName);
var
listOfObjects = db.ExecuteQuery("SELECT A1
WHERE value = 0").Cast<A1>().ToList<A1>();
This approach makes
RegisterType 5-20 times faster than tradional way.
The initial database is ¾ empty and contains space reserved for the data. Database grows is determined by a complex formula and usually makes it grow in stages. So the database size is not always determines amount of data saved – often it is a reserved space for the data.