Forums

Creating BO programatically One-Many in XAF

Last post 10/21/2008 1:37 PM by Trey Balut. 0 replies.
Sort Posts: Previous Next
  • Trey Balut

    Creating BO programatically One-Many in XAF

    10/21/2008 1:37 PM
    • Not Ranked
    • Joined on 10/21/2008
    • Posts 9

     Using the Artist-Album BOs in the Audit Demo, how would you create the Business Objects programatically at runtime?

    For example, if you create 2 Artists "Jimi Hendrix" and "John Lennon" and they are created with GUID OIDs, how would you use either or both artist to create test/sample Albums using Hendrix or Lennon as the Artists?

     

    Below is the BO class.

     

    namespace AuditDemo.Module {
     [DefaultClassOptions]
     public class Album : BaseObject {
      public Album(Session session) : base(session) { }
      private string name;
      public string Name {
       get {
        return name;
       }
       set {
        SetPropertyValue("Name", ref name, value);
       }
      }
      private int year;
      public int Year {
       get {
        return year;
       }
       set {
        SetPropertyValue("Year", ref year, value);
       }
      }
      private Artist artist;
      [Association("Artist-Albums")]
      public Artist Artist {
       get {
        return artist;
       }
       set {
        SetPropertyValue("Artist", ref artist, value);
       }
      }
      private XPCollection<AuditDataItemPersistent> auditTrail;
      public XPCollection<AuditDataItemPersistent> AuditTrail {
       get {
        if(auditTrail == null) {
         auditTrail = AuditedObjectWeakReference.GetAuditTrail(Session, this);
        }
        return auditTrail;
       }
      }
     }
     [DefaultClassOptions]
     public class Artist : BaseObject {
      public Artist(Session session) : base(session) { }
      private string name;
      public string Name {
       get {
        return name;
       }
       set {
        SetPropertyValue("Name", ref name, value);
       }
      }
      [Association("Artist-Albums")]
      public XPCollection<Album> Albums {
       get {
        return GetCollection<Album>("Albums");
       }
      }
      private XPCollection<AuditDataItemPersistent> auditTrail;
      public XPCollection<AuditDataItemPersistent> AuditTrail {
       get {
        if(auditTrail == null) {
         auditTrail = AuditedObjectWeakReference.GetAuditTrail(Session, this);
        }
        return auditTrail;
       }
      }
     }
    }

    Thanks in advance,

    Trey

     

     

     

     

More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.