is there any way to implement TransparentActivation without referencing db4o libs into model?

StackOverflow https://stackoverflow.com/questions/15861844

  •  02-04-2022
  •  | 
  •  

Question

to get directly to my point: I want to have independent object model where I won't reference any libraries of database engine so that I will be able to use that model in multiple object or document databases (such as RavenDB, db4o, eloquera etc.)

on the other hand I will be designing db4o first, so lets imagine following object model class:

public class User : IActivatable
{
    [Indexed]
    private string name;

    [Transient]
    private string securityinfo;

    ....
}

some solutions I already have (indexing, cascading):

  • [Indexed] attribute I can configure on dbconfig side like: config.Common.ObjectClass(typeof(User)).ObjectField("name").Indexed(true);
  • to remove the [Transient] attribute - ??
  • to remove IActivatable - ?? (I was thinking to use instrumetation of Postsharp which can inject implementation of the interface after compilation, but it will still need reference of Db4objects.Db4o.dll. Can Db4oTool instrumentation do that?)

so the question:

How is possible to remove reference of Db4objects.Db4o.dll from object model project and still being able to apply features like TransparentActivation and Transience (Indexing I have covered)?

Was it helpful?

Solution

Regarding the IActivatable interface, db4o does require activatable types to implement this interface; if you can live with db4o references in your model assemblies then db4otool can add the implementation for this interface for you (options -ta and maybe -collections) (so no references to db4o in your model classes at source code level and also no need to do any extra work).

Regarding the TransientAttribute, you have some options:

  • Rely on NonSerialized attribute instead
  • Specify your own attribute to be handled as transient.

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top