AdFactum ObjectMapper .NET Blog

Official blog of the AdFactum ObjectMapper .NET

How to get the primary key of an aggregated entity when doing a flat load of the parent.

Posted by Gerhard Stephan on August 16th, 2007

Today I will show you a way to retrieve the ID of an aggregated object, even when doing a flat load of the parent.

Normally when doing a flat load of an object, the aggregated child objects will stay untouched and the properties will return null. This is cool, as long you don’t need them. But out of my experience there are not only these two cases – to load the aggregated objects, or not to load. Often you don’t need the content of the aggregated object, but you need the primary key of them. For such cases you have to insert a second property which will be filled by the attribute [SelectFunction] of the AdFactum ObjectMapper .NET.

    public class Invitee : ValueObject


        Contact _invitedContact;

        /// <summary>

        /// The aggregated Contact

        /// </summary>


        public Contact InvitedContact


            get { return _invitedContact; }

            set { _invitedContact = value; }



        /// <summary>

        /// Using the Select Function the ID of the aggregated

        /// object will also be mapped, even if the object

        /// is only flat loaded.

        /// </summary>


        public Guid InvitedContactId


            get { return _invitedContactId; }

            set { _invitedContactId = value; }







Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>