Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5973835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:51:24+00:00 2026-05-22T20:51:24+00:00

I have been trying to write some generic code to create an xml package

  • 0

I have been trying to write some generic code to create an xml package of Habanero business objects. The code can currently handle compostion relationships, but I need to add the Association relationships manually. Is there any way to add association relationsips that don’t have a composite reverse relationship in a more generic way.

This is how the composition relationships are added

    private static void AddRelatedCompositionObjects(Package package, IBusinessObject businessObject)
    {
        businessObject.Relationships
            .Where(rel => rel.RelationshipType == RelationshipType.Composition)
            .Where(rel => rel is IMultipleRelationship)
            .Select(rel => (IMultipleRelationship)rel)
            .ForEach(rel => rel.BusinessObjectCollection
                                .AsEnumerable<IBusinessObject>()
                                //.ForEach(package.Add));
                                .ForEach(bo => BuildPackage(package, bo)));

        businessObject.Relationships
            .Where(rel => rel.RelationshipType == RelationshipType.Composition)
            .Where(rel => rel is ISingleRelationship)
            .Select(rel => (ISingleRelationship)rel)
            //.ForEach(rel => package.Add(rel.GetRelatedObject()));
            .ForEach(rel => BuildPackage(package, rel.GetRelatedObject()));
    }

And then I manually add the association relationships

                var package = new Package();
                foreach (var returnDelivery in returnDeliveries)
                {
                    package.Add(returnDelivery);
                    if (returnDelivery != null)
                    {
                        var materials = returnDelivery.DeliveryItems.Select(item => item.Material).Distinct();
                        materials.ToList().ForEach(material =>
                        {
                            package.Add(material);
                            material.EWTMaterials.ForEach(package.Add);
                        });
                        package.Add(returnDelivery.Customer);
                    }
                }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:51:25+00:00Added an answer on May 22, 2026 at 8:51 pm

    First thing to realise is that
    1) Habanero does not require you to have a reverse relationship defined. Although if you are generating your class definitions from Firestarter you will have one.

    I have stolen this sample snippet from the ClassDefValidator in Habanero.BO so it might not be exactly what you want and could certainly be generalised into the architecture.
    What this code snipped does is get the reverse relationshipDef for a relationshipDef

    this code is in Habanero.BO.ClassDefValidator

    CheckRelationshipsForAClassDef method if you look here you will see code to get the relatedClassDef. It should be pretty easy to convert this into something you need.

    If you have any problems then give me a shout.

            if (!HasReverseRelationship(relationshipDef)) return;
    
            string reverseRelationshipName = relationshipDef.ReverseRelationshipName;
            if (!relatedClassDef.RelationshipDefCol.Contains(reverseRelationshipName))
            {
                throw new InvalidXmlDefinitionException
                    (string.Format
                         ("The relationship '{0}' could not be loaded for because the reverse relationship '{1}' defined for class '{2}' is not defined as a relationship for class '{2}'. Please check your ClassDefs.xml or fix in Firestarter.",
                          relationshipDef.RelationshipName, reverseRelationshipName, relatedClassDef.ClassNameFull));
            }
    
            var reverseRelationshipDef = relatedClassDef.RelationshipDefCol[reverseRelationshipName];
    

    Brett

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been writing some code that creates a generic blog. Its features are
I have been trying to write some applescript that checks to see if the
I have been trying to learn how to add testing to existing code --
I have been refactoring throwaway code which I wrote some years ago in a
I have been trying to learn how to write faster more efficient jQuery and
I have been starting to write some reasonably large and or confusing MySQL queries
I have been trying to write a macro (in steps) to organize the results
I have been looking into this for some hours now and can't figure it
I'm trying to write some code to look through an image file for groups
I have been trying to work with NIO SocketChannels for some time now, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.