Can't get XAF/XPO association working as expected

15 Views Asked by At

Here is the context:

In a XAF (Winforms) solution, we have a Production object which has 2 properties:

  • string Description

  • XPCollection Products

     [Persistent(@"PRODUCTION")]
     public partial class Production : XPLiteObject
     {
         long oid;
         [Key(true)]
         [Persistent(@"OID")]
         public long Oid
         {
             get { return oid; }
             set { SetPropertyValue<long>(nameof(Oid), ref oid, value); }
         }
         string description;
         [Size(80)]
         [Persistent(@"DESCRIPTION")]
         [DbType("VARCHAR2(80 CHAR)")]
         public string Description
         {
             get { return description; }
             set { SetPropertyValue<string>(nameof(Description), ref description, value); }
         }
         [Association(@"ProductReferencesProduction")]
         public XPCollection<Product> Products { get { return GetCollection<Product>(nameof(Products)); } }
     }
    

And a Product object with, among others properties:

  • Production Production

     [Persistent(@"PRODUCT")]
     public partial class Product : XPLiteObject
     {
         long oid;
         [Key(true)]
         [Persistent(@"OID")]
         public long Oid
         {
             get { return oid; }
             set { SetPropertyValue<long>(nameof(Oid), ref oid, value); }
         }
         DateTime creation;
         [Persistent(@"CREATION")]
         public DateTime Creation
         {
             get { return creation; }
             set { SetPropertyValue<DateTime>(nameof(Creation), ref creation, value); }
         }
         DateTime modification;
         [Persistent(@"MODIFICATION")]
         public DateTime Modification
         {
             get { return modification; }
             set { SetPropertyValue<DateTime>(nameof(Modification), ref modification, value); }
         }
         string modificator;
         [Size(200)]
         [Persistent(@"MODIFICATOR")]
         [DbType("VARCHAR2(50 CHAR)")]
         public string Modificator
         {
             get { return modificator; }
             set { SetPropertyValue<string>(nameof(Modificateur), ref modificateur, value); }
         }
         Production production;
         [Persistent(@"PRODUCTION")]
         [Association(@"ProductReferencesProduction")]
         public Production Production
         {
             get { return production; }
             set { SetPropertyValue<Production>(nameof(Production), ref production, value); }
         }
     }
    

The problem is when we create a new Product inside a Production, it does not link them together. In the database, the field Production remains empty.

Any idea what we are missing?

0

There are 0 best solutions below