deveton
deveton

Reputation: 341

How to make XPO one-to-one relationship with a simple code?

Shortly, Here's a code. It doesn't work.

  1. I try to insert property with same key in both table.
  2. DevExpress tickets doesn't resolve it also First Ticket and Second Ticket
  3. See First Ticket link. see last reply. That what I do here. not working.

DevExpress First Ticket Last Comment-> To implement this relationship, do not add any relationship object from the designer's toolbox. Instead, create two properties - a property of the MasterBusinessPartner type for the MasterCustomers class and a property of the MasterCustomer type for the MasterBusinessPartner class. This will be sufficient to generate the code you demonstrated in the first code snippet. If you want to implement additional synchronization logic, similar to what is shown in the How to: Implement One-to-One Relationships topic, you can override the OnChanged method, as described in the ORM Wizard one-to-one relation partial classes ticket.

My Schema ( 2 Tables one-to one) Each menu only have single MenuBLOB row. schema

[Persistent("Menu")]
public class Menu : XPLiteObject
{
    [Key, Association("kk")]
    public MenuBLOB MenuKey { get; set; }

    public long MenuID { get; set; }

    public Menu(Session session) : base(session) { }      
    public Menu(Session session, XPClassInfo classInfo) : base(session, classInfo) { }
}

[Persistent("MenuBLOB")]
public class MenuBLOB : XPLiteObject
{
    public long MenuID { get; set; }
    public string Base64Value { get; set; }

    [Key, Association("kk")]
    public Menu MenuKey { get; set; }


    public MenuBLOB(Session session) : base(session) { }
    public MenuBLOB(Session session, XPClassInfo classInfo) : base(session, classInfo) { }
}

Exception of type 'System.StackOverflowException' was thrown

Upvotes: 1

Views: 337

Answers (1)

Michael de Vlieger
Michael de Vlieger

Reputation: 88

Create a different property for the KeyAttribute (In this case MenuId seems most Likely)

Upvotes: 0

Related Questions