Building Graphs with Business Objects

Building Graphs with Business Objects

Old forum URL: forums.lhotka.net/forums/t/4383.aspx


Patrick posted on Wednesday, February 20, 2008

Hi,

I have a challenge and was wondering how other solved (would solve) this with CSLA.NET

I have a graph structure of nodes and edges:

The prototype looks like this:

Tables:
Edges:
- NodeId (int)
- ChildNodeId (int)
Nodes:
- NodeId (int)
- NodeName (varchar())
- ...
Business objects:
- NodeList (EditableRootList)
-- Node        (EditableChild)
--- EdgeList (EditableChildList)
---- Edge     (EditableChild)

NodeList properties:
Node properties

This works quite ok but the there are some difficulties with persisting the graph:
Other point which this solution doesn't cover:

I was wondering what other approaches you might have taken or would take.
Smile [:)]

Thanks a lot for your feedback,
Patrick

JoeFallon1 replied on Thursday, February 21, 2008

Patrick,

1. Your posts are always interesting.

2. One thing you might consider is creating a Use Case Controller object. This is a normal root level BO which contains the other BOs you are discussing.

When you Create a New controller BO you might pass it the rootID and then it instantiates all the other BOs as normal.

The advantage you now have is that the controller has access to all the Bos in side of it and can enforce rules and such.

In this case you can also call DataPortal_Update on the controller BO and then you can decide within its Update method how to do the save of your objects.

Since the standard Save of your root BO fails you can now step back and do something different.

e.g. Loop over a child collection and insert all new nodes first, then insert Edges.

Joe

 

 

 

Patrick replied on Thursday, February 21, 2008

JoeFallon1:
1. Your posts are always interesting.
Thank you

JoeFallon1:
2. One thing you might consider is creating a Use Case Controller object.
Yes very good idea.

Here are some more threads on the topic

I'm still looking forward to some more feedback :)

Thanks a lot,
Patrick

Copyright (c) Marimer LLC