how to map data to a child...

how to map data to a child...

Old forum URL: forums.lhotka.net/forums/t/10559.aspx


Troy posted on Monday, July 25, 2011

Hi,

I have a child object called MessageGroups (the parent is Message), now MessageGroups is a List which has an Editable business object call MessageGroup, the below line ( Csla.Data.DataMapper.Map(item, info);) fails because info is null, however I don't know how to create an instance of MessageGroup because the factory methods within the MessageGroup class are declared as static internal.  Code snippet is below.

I don't see an equivalent implementation of this int he ProjectTracker sample app so I'm not sure the best way to map the properities.

//map message details
Csla.Data.DataMapper.Map(messageData, message, messageDataIgnoreList);

//map message groups
if (messageData.MessageGroups != null)
{
    MessageGroups groups = null;
    foreach (MessageGroupData item in messageData.MessageGroups)
    {
        MessageGroup info = null;
        Csla.Data.DataMapper.Map(item, info);
        groups.Add(info);
    }
        message.GroupRecipients = groups;
}

 

Troy

JonnyBee replied on Monday, July 25, 2011

Try this:       

MessageGroups groups = MethodCaller.CreateInstance(typeof(MethodGroups));

MessageGroup info = MethodCaller.CreateInstance(typeof(MessageGroup));

Troy replied on Monday, July 25, 2011

That did it!  Thanks so much!

Troy

Copyright (c) Marimer LLC