Subsonic foreign key returning collection?

ⅰ亾dé卋堺 提交于 2019-12-12 01:34:37

问题


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?


回答1:


That is expected behavior. The first (and only) item in the Invoice.Customers collection will be the foreign key related Customer object.



来源:https://stackoverflow.com/questions/2950692/subsonic-foreign-key-returning-collection

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!