Pergunta

I am developing a DevExpress XAF application that has the following business objects

Employee Warehouse ​Applicant

Each of these entities can have one or more Email Addresses

How can I accomplish this using a single EmailAddress Business Object​?

Foi útil?

Solução

You can introduce a base persistent class with a collection of EmailAddress objects (http://documentation.devexpress.com/#Xaf/CustomDocument2733) and then inherit your other classes from it. As an alternative to inheritance, you can use aggregation.

However, I am not quite sure exactly what you mean by "using a single EmailAddress Business Object​", may be you do not need a collection property as I suggested above.

P.S. To get a guaranteed and fast assistance with DevExpress products, please use the official Support Center (http://www.devexpress.com/Support/), access to which is free during the evaluation period.

Outras dicas

" Each of these entities can have one or more Email Addresses"

Going by the statement above, what I could make out is, you got Employee as a business object and these entities can have multiple EmailIds. What I would suggest is you create EmailId as another business object with only one property EmailIdand have a 1 -to- * relationship between your Employee and EmailId business objects. Do not forget to hide your business object EmailId from navigation items. EmailId should only be visible to users creating new Employee objects and otherwise it should not be allowed to be created, independent of any relation.

I know this is a very late answer to a question, but let us know how you solved your problem. By doing this, you can help others facing a similar situation that you were in. Thanks.

Create a email class with no link back to any other class. Then create the class that needs to have a collection of emails. Now you have two choices. You can add more than one back link to the email class with the right association for each parent class or you can create separate child (email) classes for each parent. The child will inherit from email and only add the back link to the parent class.

You can use this type; (I use XPLiteObject if you want to auto generate key you can use XPObject)

public class Person : XPLiteObject
{
    public Person(Session session)
        : base(session)
    {
    }
    public override void AfterConstruction()
    {
        base.AfterConstruction();

    }
    [Association("PersonEmails", UseAssociationNameAsIntermediateTableName = true)]
    public XPCollection<Email> Emails
    {
        get
        {
            return GetCollection<Email>("Emails");
        }
    }



}

public class Email : XPLiteObject
{
    public Email(Session session)
        : base(session)
    {
    }
    public override void AfterConstruction()
    {
        base.AfterConstruction();

    }

    private Person person;
    [Association]
    public Person Person
    {
        get { return person; }
        set { SetPropertyValue("Person", ref person, value); }
    }

}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top