Aliases allow you to use different names for your persistent classes in the database and in your application. Before a class is saved, db4o checks if an alias exists. If this is the case, the alias-name is used instead of the original name.
You can add aliases by adding instance of the Alias-interface to the configuration. You can add as many aliases to the configuration as you want. Following options are available.
Each alias has two arguments. The first argument it the name which the type has in the database. The second argument is the type which is currently used. Ensure that you alias only types which can be resolved.
Note that in .NET the types-names contain the full namespace, classname and the assembly-name. For example the when you have an assembly called 'MyProject', a namespace 'Company.Project' and a class named Person, then the name of the type is: 'Company.Project.Person, MyProject'
Furthermore the order in which you add the aliases matters. Add first the most specific alias and the go to the more general alias. For example add first all TypeAlias and then the WildCardAlias.
// add an alias for a specific type configuration.Common.AddAlias( new TypeAlias("Db4oDoc.Code.Configuration.Alias.OldTypeInDatabase, Db4oDoc", "Db4oDoc.Code.Configuration.Alias.NewType, Db4oDoc")); // or add an alias for a whole namespace configuration.Common.AddAlias( new WildcardAlias("Db4oDoc.Code.Configuration.Alias.Old.Namespace.*, Db4oDoc", "Db4oDoc.Code.Configuration.Alias.Current.Namespace.*, Db4oDoc"));
' add an alias for a specific type configuration.Common.AddAlias(New TypeAlias("Db4oDoc.Code.Configuration.Alias.OldTypeInDatabase, Db4oDoc", _ "Db4oDoc.Code.Configuration.Alias.NewType, Db4oDoc")) ' or add an alias for a whole namespace configuration.Common.AddAlias(New WildcardAlias("Db4oDoc.Code.Configuration.Alias.Old.Namespace.*, Db4oDoc", _ "Db4oDoc.Code.Configuration.Alias.Current.Namespace.*, Db4oDoc"))