亚音速外键返回集合? [英] Subsonic foreign key returning collection?
问题描述
我正在使用 Subsonic 编写我的第一个Hello World"程序,为此我已经将一个简单的客户/发票/InvoiceItem/Product 数据库放在一起.
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.
已成功连接到数据库,并生成了所有正确的 ActiveRecord
类.但是由于某种原因,Invoice
类有一个名为 Customers
的属性,它返回一个 Customer
对象的集合,即使 Invoice
表有一个 CustomerID
字段,该字段具有 Customer
表的外键.我希望 Customer
属性返回单个 Customer
对象.
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.
同样的事情发生在我所有的 FK 身上.我一定是做错了什么 - 但什么?
Same thing is happening for all of my FKs. I must be doing something wrong - but what?
推荐答案
这是预期的行为.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.
这篇关于亚音速外键返回集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!