ObjectFactory and Child Objects.

ObjectFactory and Child Objects.

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


admin posted on Monday, April 05, 2010

Hello,

How should one treat Child Fetch calls when using the ObjectFactory? I have an EditableChild or a ReadOnlyChild and my code looks like this:

  internal static SettingGroupList GetByApplicationID(System.Int32 applicationID)

        {

            return DataPortal.FetchChild< SettingGroupList >(

                new SettingGroupCriteria{ApplicationID = applicationID});

        }

It doesn't work because ChildPortal methods are never invoked but I need to call the ObjectFactory Implementation. Should I always just have them call the Regular Fetch? Is there a best practice for this?

        internal static SettingGroupList GetByApplicationID(System.Int32 applicationID)

        {

            return DataPortal.Fetch< SettingGroupList >(

                new SettingGroupCriteria{ApplicationID = applicationID});

        }

Thanks

-Blake Niemyjski

RockfordLhotka replied on Monday, April 05, 2010

The child data portal is not compatible with the object factory.

When using the object factory model, the factory is responsible for creating and initializing child objects as well as root objects.

You might consider having the root object factory create and invoke other "child" object factories - but this isn't something the data portal will do for you. When you are in object factory land, you are on your own.

Copyright (c) Marimer LLC