I trying out db4o to build an ERP system.All went well until trying to update a structure like this: (shorttened)
public Company{ public IList<Module> Modules{get;set;}
//in the constructor I initalize this with : Modules = new List<Module>();}
It seems that the first time I store the instance of a company all going well.However: loading the company, adding a module to the modules list and than trying to store (update) will refuse to store the new updated list.No error will occur but the next time I execute the application the modules list is without the addtional module.Even without restarting the application trying few times to read the instance of the company will eventually show the truth - which is the addtional module was not really saved.I'm using the stable version 7.4 for .net 3.5.PLEASE HELP! I DON'T WANT TO GO BACK TO SQL!!!Regards,Gil
Have you configured the right update-depth? When you update an object, only its direct members (ints, floats, strings) will be updated. The list is considered as a reference to another objects. So you have to store it explicit or set the update-depth higher:
http://developer.db4o.com/Resources...date_Depth
http://developer.db4o.com/Resources...ed_Objects
Yes I did.
I tried setting:Db4oFactory.Configure().ObjectClass(typeof (Companyt)).UpdateDepth(10);Db4oFactory.Configure().ObjectClass(typeof (Sample)).CascadeOnUpdate(true);It didn't solve anything - I got the exact same behavior as before.
I tried the followings with no success,Db4oFactory.Configure().ObjectClass(typeof(Company)).UpdateDepth(10);
Db4oFactory.Configure().ObjectClass(typeof (Company)).CascadeOnUpdate(true);
getting the exact same behavior..
Hi.
On version 7.4 generic collections handling has issues.
These issues were fixed on version 7.7. (For more information take a look at http://developer.db4o.com/forums/th...2219.aspx)
Can you try with latest version ?
Best
Adriano
Thanks Adriano,
Here are the results while trying the same tests with the following versions:db4o 7.7 for asp.net 3.5 - same results - it is not working.db4o 7.10 for asp.net 3.5 - same results - it is not working.This either means "it is not working" or i'm not using it correctly, so if possible:I'd like to see a working example of C# .Net 3.5 (vs2008) application able to store and afterwards update an object with generic collections of non-primitve type.ThanksGil.
I think I've got what you're writing about and I received the same situation.
Now I've got the working code that should solve your issue. if you want I can put it here with explanations or put on file storage somewhere (or send on e-mail, if you want)
in a few words, you should change the configuration with adding special configuration line for the Container class (class that owns the collection)
you should specify CascadeOnUpdate(true) for this class.
please send me to this email: gil.yadid@gmail.com
Thank You!!The code is for vs2008 .net 3.5 I hope.
This issue is solved thanks to Adriano and to RST.
The solution is to use : DB = Db4oFactory.OpenFile(Db4oFactory.Configure(), DBPath);Db4oFactory.Configure().ObjectClass(typeof(Sample)).CascadeOnUpdate(true);
The problem was I used:DB = Db4oFactory.OpenFile(DBPath);Db4oFactory.Configure().ObjectClass(typeof(Sample)).CascadeOnUpdate(true);
As you can see I was assuming that the global configuration is being taken into considration by default.However it is not...I suggest either a global configuration be taken into considration by defaultOR to change the name in the documantion from "global configuration" to "stand-alone configuration" and to mention that it is not activated by default.Thank you,Gil.
One last note: it was tested for v7.10 for .net 3.5, I didn't test it for 7.4.
Hi
May it be a "activation depth" problem?
Regarding a sample, I guess that you can look either in the turorial or in db4o test suite.
Let me known If you have any problem finding the samples.