亚音速外键返回集合?
我正在使用 Subsonic 编写我的第一个“Hello World”程序,为此我构建了一个简单的小型 Customer/Invoice/InvoiceItem/Product 数据库。
与数据库的连接已成功建立,并且生成了所有正确的 ActiveRecord
类。但由于某种原因,Invoice
类有一个名为 Customers
的属性,它返回 Customer
对象的集合,即使 Invoice
表有一个 CustomerID
字段,该字段具有 Customer
表的外键。我希望 Customer
属性返回单个 Customer
对象。
我所有的 FK 都发生了同样的事情。我肯定做错了什么——但是什么?
I'm just writing my first "Hello World" program using Subsonic, for which I've thrown together a simple little Customer/Invoice/InvoiceItem/Product database.
The connection was successfully made to the DB, and it generated all the right ActiveRecord
classes. But for some reason, the Invoice
class has a property called Customers
, which returns a collection of Customer
objects, even though the Invoice
table has a CustomerID
field which has a foreign key to the Customer
table. I would have expected a Customer
property returning a single Customer
object.
Same thing is happening for all of my FKs. I must be doing something wrong - but what?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是预期的行为。 Invoice.Customers 集合中的第一个(也是唯一一个)项目将是与外键相关的 Customer 对象。
That is expected behavior. The first (and only) item in the Invoice.Customers collection will be the foreign key related Customer object.