in

CodeSmith Community

Your Code. Your Way. Faster!

Is there a problem with deep DeepLoad?

Last post 12-26-2006 4:36 PM by vcif. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 12-22-2006 5:16 PM

    • velum
    • Top 25 Contributor
    • Joined on 07-14-2006
    • Montréal, Qc, Canada
    • Posts 186
    • Points 4,686

    Is there a problem with deep DeepLoad?

    Hi!

    I tried to load a complex object with DeepLoad, but only one level got loaded even though I turned on the "deep" flag.

    Here is a simplified version of my schema

    ClientCoor (ClientCoorID, ZipCodeID, ...)
    ZipCode (ZipCodeID, CityID, RegionID, CountryID, ...)
    City (CityID, CityName)

    And here is my code:

                ClientCoor clientCoor;
                ClientCoorService clientCoorService = new ClientCoorService();
                clientCoor = clientCoorService.GetByClientCoorID(1);
                clientCoorService.DeepLoad(clientCoor, true);

    After  running this code, I would have expected to be able to access the following object and sub-objects:

    •  clientCoor
    • clientCoor.ZipCodeIDSource
    • clientCoor.ZipCodeIDSource.CityIDSource
    • clientCoor.ZipCodeIDSource.RegionIDSource
    • clientCoor.ZipCodeIDSource.CountryIDSource

    However, I can only access the two first ones. The three latter ones are null. Is there anything wrong with my code?

    Cheers!

    JF

     

    Filed under:
    • Post Points: 95
  • 12-26-2006 4:16 PM In reply to

    • Faldaani
    • Top 150 Contributor
    • Joined on 10-22-2006
    • Posts 30
    • Points 550

    Re: Is there a problem with deep DeepLoad?

    I've had similar problems, although I would be able to access the first 3 ones... I spent way too much time on the issue and manually loaded the rest of them.

     

    • Post Points: 5
  • 12-26-2006 4:23 PM In reply to

    • jmartinez
    • Not Ranked
    • Joined on 12-05-2006
    • Posts 7
    • Points 95

    Re: Is there a problem with deep DeepLoad?

    Instead of using:

    clientCoorService.DeepLoad(clientCoor, true);

    You should use:

    clientCoorService.DeepLoad(clientCoor, true, DeepLoadType.IncludeChildren, typeof(ZipCode), typeof(City), typeof(Region), typeof(Country));

    • Post Points: 5
  • 12-26-2006 4:36 PM In reply to

    • vcif
    • Top 50 Contributor
    • Joined on 06-18-2006
    • Posts 69
    • Points 1,510

    Re: Is there a problem with deep DeepLoad?

    jmartinez code will NOT work. 

    I was going to bring this up after my One to One deepload question was answered.

    If you look at the DeepLoad functions for the sources they are called as follows

    #region OutcomesTypeIDSource

    if (CanDeepLoad(entity, "OutcomesType|OutcomesTypeIDSource", deepLoadType, innerList)

    && entity.OutcomesTypeIDSource == null)

    {

    object[] pkItems = new object[1];

    pkItems[0] = entity.OutcomesTypeID;

    OutcomesType tmpEntity = EntityManager.LocateEntity<OutcomesType>(EntityLocator.ConstructKeyFromPkItems(typeof(OutcomesType), pkItems), DataRepository.Provider.EnableEntityTracking);

    if (tmpEntity != null)

    entity.OutcomesTypeIDSource = tmpEntity;

    else

    entity.OutcomesTypeIDSource = DataRepository.OutcomesTypeProvider.GetByOutcomesTypeID(transactionManager, entity.OutcomesTypeID);

    }

    #endregion OutcomesTypeIDSource

    the two issues with this are: 1) as you noted the sources are not deeploaded for which there may be some good reasons of which we are unaware(like massive loading of the object graph) 2) why restrict loading the source to only if it is null? what if the source has changed? shouldn't it be reloaded as requested? the child collections  are reloaded regardless of  whether they are are null or already loaded as below

    #region OutcomesReoperationCollection

    //Relationship Type One : Many

    if (CanDeepLoad(entity, "List<OutcomesReoperation>|OutcomesReoperationCollection", deepLoadType, innerList))

    {

    #if NETTIERS_DEBUG

    Debug.WriteLine("- property 'OutcomesReoperationCollection' loaded. key " + entity.EntityTrackingKey);

    #endif

    entity.OutcomesReoperationCollection = DataRepository.OutcomesReoperationProvider.GetByOutcomesHeaderID(transactionManager, entity.OutcomesHeaderID);

    if (deep && entity.OutcomesReoperationCollection.Count > 0)

    {

    deepHandles.Add(

    (DeepLoadHandle< OutcomesReoperation >) DataRepository.OutcomesReoperationProvider.DeepLoad,

    new object[] { transactionManager, entity.OutcomesReoperationCollection, deep, deepLoadType, childTypes, innerList }

    );

    }

    }

    #endregion

    for now you will have to manually load them. perhaps the best way would be to define your own procedure in the nongenerated provider class and use a custom sp to get the data you need. robert has put up good examples of doing this but i dont have the links handy

    hope we can get some understanding of these issues

    vin

    • Post Points: 5
Page 1 of 1 (4 items)
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems