Back to UsefulDB4O in ASP.NET
If ,on the definition of the databases, do not specify anything, the db4o database will open with the default configuration settings.
To customize these settings should follow the next steps:
namespace ExampleLibray { public static class DatabasesConfiguration { public static IServerConfiguration GetDatabaseProductsConfiguration() { var databaseConfig = Db4oClientServer.NewServerConfiguration(); databaseConfig.Common.ActivationDepth = 0; databaseConfig.Common.StringEncoding = StringEncodings.Unicode(); databaseConfig.Common.WeakReferences = false; return databaseConfig; } } }Line 7: get an empty instance of the class configuration
Line 9,10,11: we set the settings that most interest us.
Line 13: Return the configuration we created for the database
<db4o> <databases> <database alias="ProductsDatabase" serverType="EmbeddedServer" openServerRetriesOnLock="10" fileDb4oPath="/App_Data/products.db4o" assemblyWithDatabaseConfig="ExampleLibrary" staticMethodWithDatabaseConfig="ExampleLibrary.DatabasesConfiguration.GetDatabaseProductsConfiguration" /> </databases> </db4o>
Line 8: indicate the name of the assembly containing the class with the method ofconfiguration. It can be the same assembly of the application or another. In case of using the App_Code folder indicate "App_Code" in the attribute assemblyWithDatabaseConfig and in the attribute staticMethodWithDatabaseConfig only indicate class name + method name.
Line 9: signature (name) full static method that returns the configuration of our database
Back to UsefulDB4O in ASP.NET