I didn’t find anywhere whether is possible to query from Db4o all objects implementing some generic interface
for example:
to query all objects implementing IList<T>, I tried:
var items = from IList<object> item in session
select item;
but this doesn’t return all lists in database (only the ones which implements specificaly IList<object>)
Is there any way to do it other then query all objects from database, loop them and evaluate the object manually? (I would have to pass through milions of objects in this case)
Thank you
You want to query for all objects which are any instance of the IList<> type. Or other costume generic types.
In my opinion this is not possible at the moment. The reason is that db4o treats each instance of a List<> as its own type. So a List and a List are stored a two different types. This goes right down to the meta data storage in db4o, where those are stored separately. This also means that there not shared index for all instance of the different List<> types.
Btw in Java it is the other way around, all types of List<> are treated as the same type, since in Java generics are not reflected at runtime.
So, you basically need to go over all the different types of List<> yourself to get all instances.
For your own types I would create an abstract non generic class which the generic instance inherit. Then you can query for that and get all generic subtypes. Note that this doesn’t work for interfaces, since db4o doesn’t index or keep meta-infos for interfaces.