Ticket S130253
Visible to All Users

Add Support for One-Way Associations

created 16 years ago

One-Many and Many-Many associations require that the object model contains an end point at each end of the association. This is not always convenient and imposes an artifical constraint on the object model.
Could you please add support for one-way associations, such as:
public class Customer: XPObject
{
   public XPCollection<Order> Orders {…}
}
public class Order: XPObject
{
   // No association back to Customer!
}
This article in the forums is a related discussion:
http://community.devexpress.com/forums/p/70054/239050.aspx#239050
Thanks
Sean
Proposed Solution:
Maybe use a link table to store the one-way associations, as you do for many-many associations.

Show previous comments (9)
DevExpress Support Team 16 years ago

    Hi Sean,
    We've been discussing your suggestion, trying to figure out the real-world task it solves. If we understand you correctly, you only want to simplify the code by not having to declare one of the required properties in associated classes.
    A one-to-many association in XPO is a linkage between two persistent classes. According to XPO's association design, the class on the "many" side must hold a reference to the class that represents the "one" side. This is a mandatory requirement put into the foundation of XPO's one-to-many associations. That is, if you want to establish a one-to-many association via the Association attribute and the GetCollection method, you must declare referencing properties in both classes.
    However, nothing can stop you from developing one-way association as shown in my previous message. This approach allows you not to add a backward reference property to the dependent class, when it's not required.
    To sum it up, we think that the current design of one-to-many associations in XPO is reliable and transparent. We are not going to change it, unless we have strong arguments for doing so.
    Thanks,
    Nick

    DevExpress Support Team 16 years ago

      Hi Nick
      Thanks for the explanation and the consideration of my request. If always having two-way multi associations is a fundamental principle of XPO class design, then I can see that you are nto going to want to change from that. I would like to update my blog - I presume that you do not mind me quoting your response below? Quoting it in a favourable light, of course!
      Thanks again for your time and consideration of the request.
      Regards
      Sean

      DevExpress Support Team 16 years ago

        Hello Sean,
        Yes, please feel free to quote me in your blog. Should you have new technical questions, please don't hesitate to ask - I'll be happy to assist you.
        Thanks,
        Nick

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.