在 Castle Active Record 中创建外键对象
我有一个项目,我使用 Castle Active Record 作为 DAL 技术。
我的对象关系是这样的...
Route
包含许多Waypoints
。
我想要做的是向路线添加一个航路点,而不从数据库中检索路线,但我不太清楚该怎么做。
我已经知道路线 ID,所以这不是问题。在保存之前使用正确的 ID 初始化路线并将其分配给航路点 Route 属性是否会实现此结果?
谢谢 本
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,既然有人喜欢这个问题,我就自己回答吧,因为我现在知道答案了。如果有人对此有疑问,那么他们可以进行任何标记或任何需要发生的事情。
在保存之前使用正确的 ID 初始化路线并将其分配给航点 Route 属性足以将航点链接到现有路线。
我想我没有找到任何相关文档,因为它只是一个简单的解决方案。
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.