in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

Creating BO programatically One-Many in XAF

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

    Creating BO programatically One-Many in XAF

     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

     

     

     

     

Page 1 of 1 (1 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED