Print Page | Close Window

IsPendingEntity always false

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2434
Printed Date: 13-Mar-2025 at 5:28am


Topic: IsPendingEntity always false
Posted By: tj62
Subject: IsPendingEntity always false
Date Posted: 13-Jan-2011 at 6:29am
Hi,
Using DevForce versoin 6.0.6.0 for Silverlight:
I'm starting using navigation properties in Silverlight making use of the PendingEntityResolved such when an image is requested by the parent entity (building entity, EntBuilding) i retrive the image-navigation property (EntImage): 

// This is a code snipped from my view model.
// A databound blob, a Value converter in the XAML takes care of valu conversion andis  proofed to work
  public byte[] p_image /
        {
            get
            {
                if (p_currentItem == null)  // If no item is selected return null
                    return null;
                EntBuilding b = (EntBuilding) p_currentItem; // The type is guranteed to be EntBuilding

// Some test commented out
                // var test = EntBuilding.PropertyMetadata.p_image.GetEntityReference(b);
                // test.IsLoaded = false;

                if (b.p_image.EntityAspect.IsPendingEntity) // always returns false!!
                {
                    b.p_image.EntityAspect.PendingEntityResolved += OnPendingEntImageResolved;
                }
                return b.p_image.p_image;
            }
        }

        private void OnPendingEntImageResolved(object sender, PendingEntityResolvedEventArgs e)
        {
            if (p_currentItem is EntBuilding)
                RaisePropertyChanged("p_image");
        }

The strange thing is that b.p_image.EntityAspect.IsPendingEntity is allways false, although it has not been loaded. 
After investigating my Entity model better I notice that all not-loaded navigation propertis are having IsPendingEntity = false but GetEntityReference(xx).IsLoaded = false. The same is tro for IsPendingEntityList. It is allways true alothugh the navigatoin collectoin properties have not been loaded.

How can that be?
PS: I'm using Entity Model against INformis Dynamic Server version 11.5 without any problems until now.



Replies:
Posted By: tj62
Date Posted: 13-Jan-2011 at 7:23am
Found the reason. Well one should never copy/paste from Ward Bell without reading the code :-). I had copied in some code from the PrismExplorer. In his repository class query method he calls:

p_entityManager.DefaultQueryStrategy = QueryStrategy.Normal; // Ensure going to data source

and then in the callback he calls:
p_entityManager.DefaultQueryStrategy = QueryStrategy.CacheOnly; // Prevent accidental async lazy loads

This of course stops everyting and causes IsPendingEntity = false all the time.

So the solution was to comment out the line in the callback and after that everything works fine!...Actualy I refined this stuff a little. Wards code is a little bit too simple :-)





Print Page | Close Window