Search code examples
.netcastle-activerecord

Creating foreign key objects in Castle Active Record


I have a project which I've used Castle Active Record as the DAL technology.

My object relationships are like this...

A Route contains many Waypoints.

What I want to do is add a waypoint to a route without retrieving the route from the database but I can't quite work out how to do it.

I already know the route ID so thats not a problem. Will initialising a route with the correct ID and assigning it to the waypoints Route property before I save achieve this result?

Thanks Ben


Solution

  • Okay, since someone favourited this question I'm gonna answer it myself since I now know the answer. If anyone has a problem with that then they can do any flagging or whatever needs to happen.

    Initialising a Route with the correct ID and assigning it to the waypoints Route property before you save is enough to link the waypoint to the existing route.

    I guess I didn't find any documentation for it because it's just such a simple solution.