AkilaI
AkilaI

Reputation: 131

GraphDiff: rearrange children in a object hierarchy and save updated details

I use GraphDiff to save detached object hierarchy which represent the following data model,

project -> course -> module -> topic.

Problem is when I try to reorder the object hierarchy from,

            Project 
            |_ Course A
            |  |_Module A
            |    |_Topic A
            |
            |_Course B
               |_Module B
                 |_Topic B

to

                    Project 
                    |_ Course A
                    |  |_Module A
                    |  | |_Topic A
                    |  |
                    |  |_Module B
                    |    |_Topic B
                    |
                    |_Course B

I have updated the Module B's course_id to Course A id and used to graphdiff to save the object hierarchy to the database, which resulted data losses (e.g Topic B was deleted from the database after saving). This is how I save project object using graphdiff.

context.UpdateGraph(project, map => map.OwnedCollection(c => c.Courses,
                     with => with.OwnedCollection(m => m.Modules,
                       with1 => with1.OwnedCollection(t =>t.Topics))));

What I want is to rearrange children in a object hierarchy without loosing information (object tree can contain changes in course, module and topic details). Further can someone provide good tutorial on draphdiff with different examples, since I am new to this :)

Thank you.

Upvotes: 1

Views: 73

Answers (0)

Related Questions