This project is read-only.

Cascade Update or Delete

May 6, 2013 at 7:20 AM
I have wrote a program to test Ndatabase. And I find NDatabase will update object field automatically. But will not delete object field when delete object. For a example, class A with one field "List<string>". When store A object, will store List<string> object to NDatanase too. But when delete, will only delete A object. and the List<string> still store in NDatabase. So I need write delete trigger to do this.

So in a project, you should check all object and write delete trigger for each object, to ensure it will not leave too many garbage in NDatabase.

If possible, may add a field attribute like [CascadeDelete], used when define object class. Mark this field is need to delete when object is deleted.

Or NDatabase will do garbage collection automatically?
May 6, 2013 at 8:15 PM
Hello,
I had several thoughts about that, there is even raised issue (new feature) for that with some first details: https://ndatabase.codeplex.com/workitem/830

If that's what you want to have, pls vote for it.

In some point of time I would like to implement that, but firstly the way of how data is stored needs to be changed.

Regards,
Jacek
May 7, 2013 at 4:03 AM
Hello, I have download source code, and add some code to do that. It look working fine on my test program.
1.First add CascadeDeleteAttribute class.
2.At ClassIntrospector.cs add one new function public static IList<FieldInfo> GetAllCascadeDeleteFieldsFrom(Type type);
3.At StorageEngine.cs's public override OID Delete<T>(T plainObject) function after fire before triggern run the fllow code
 IList<System.Reflection.FieldInfo> fields = NDatabase.Odb.Core.Layers.Layer1.Introspector.ClassIntrospector.GetAllCascadeDeleteFieldsFrom(plainObject.GetType());
 foreach (System.Reflection.FieldInfo fi in fields) this.Delete(fi.GetValue(plainObject));
I also add trigger interface and fire them at every place before you call iTriggerManager, that can keep original trigger function, and let trigger have oo's Inheritance and polymorphism.

I re-build it and use it myself.

I do not know if you don't want modify the source code by others, if not, please let me know.Thank you!
May 7, 2013 at 6:46 AM
Hello,
I will write couple of tests for that and then I will add it to the code, sounds like good idea to solve problem mentioned by you.

Still there will be deleted objects on disk, which in some point of time should be deleted. I will work in the future on space re-usability more.

Thanks,
Jacek
May 12, 2013 at 5:54 PM
Edited May 12, 2013 at 5:54 PM
Cascade Update is released with NDatabase 3.8
May 13, 2013 at 6:12 AM
Hello jacek
Is this link http://docs.ndatabase.net work properly?
Because I always can not enter this site.

I want to see what you update at v3.8 and how to use new function.
Have others way to see these document? Thanks



2013/5/13 jacek <[email removed]>

From: jacek

Cascade Update is released with NDatabase 3.8

Read the full discussion online.

To add a post to this discussion, reply to this email ([email removed])

To start a new discussion for this project, email [email removed]

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


May 14, 2013 at 6:00 PM
It is working on desktop browsers only, what kind of browser you are using?

Thanks,
Jacek
May 15, 2013 at 6:50 AM
Windows7 X64 with Google Chrome
I try IE, but still can't connect. Always time out. >_<!!


JasonTsay


2013/5/15 jacek <[email removed]>

From: jacek

It is working on desktop browsers only, what kind of browser you are using?

Thanks,
Jacek

Read the full discussion online.

To add a post to this discussion, reply to this email ([email removed])

To start a new discussion for this project, email [email removed]

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


May 15, 2013 at 10:16 AM
Hey,
on the same configuration it's working well for me (http://docs.ndatabase.net/). I tried different computers with different browsers and page is working well in all of this places.

Thanks,
Jacek
May 15, 2013 at 10:27 AM
I am at Asia, Taiwan. Still can't connect.


2013/5/15 jacek <[email removed]>

From: jacek

Hey,
on the same configuration it's working well for me (http://docs.ndatabase.net/). I tried different computers with different browsers and page is working well in all of this places.

Thanks,
Jacek

Read the full discussion online.

To add a post to this discussion, reply to this email ([email removed])

To start a new discussion for this project, email [email removed]

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


May 16, 2013 at 6:30 AM
Hello,
no idea why that's not working. Maybe you could try some proxies to check if that help? I could produce PDF documentation covering the same, if you want.

Regards,
Jacek
May 16, 2013 at 8:20 AM
Hello Jacek

It's working fine. I saw, I've to decorate the fields in each subclass too.
But: If I delete an object,, it seems the DB is not shrinking. The file size always grows up.
Is there a method to shrink the Database?
May 16, 2013 at 8:26 AM
Please see: https://ndatabase.codeplex.com/workitem/830. Other way to do that is to use DefragmentTo method which is moving only active objects to new db.
May 16, 2013 at 9:55 AM
Where can I find the method "DefragmentTo" ? Is there an example for it?
May 16, 2013 at 11:03 AM
var _db= NDatabase.Odb.OdbFactory.Open(old_db_file_path);
_db.DefragmentTo(new_db_file_path);
Sep 1, 2014 at 4:58 PM
Hello,

I tested the latest Download NDatabase.3.8-v4.0.zip,
but DeleteCascade still not working.
Isn't it implemented now?

best regards,
Zim