New Posts New Posts RSS Feed: Navigation property trouble
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Forum LockedNavigation property trouble

 Post Reply Post Reply
Author
tjuncewicz View Drop Down
Newbie
Newbie


Joined: 24-May-2011
Posts: 3
Post Options Post Options   Quote tjuncewicz Quote  Post ReplyReply Direct Link To This Post Topic: Navigation property trouble
    Posted: 24-May-2011 at 1:02pm
Does anyone know of an issue of using the EntityCacheState returned from an InvokeServerMethodAsync call when it comes to navigation properties?  We retrieve a master object in the RPC, using an Include() to make sure the details are also returned, then return the entire ECS.  We merge the ECS back into our main EM in our callback function, but whenever we access the master object's navigation property it still goes back to the server to get the details, even through the details were returned as part of the ECS.  Is the serialization/deserialization process "losing" the navigation property "linkage"?
 
Thanks.
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 24-May-2011 at 6:08pm
Hi tjuncewicz;

I was not able to repro this. This might be an old bug that has been fixed in the latest 6.1.0 version.  What DevForce version are you using?

I've included my test below.

RPC Method

    [AllowRpc]
    public static EntityCacheState GetCustomerWithOrders(IPrincipal principal, EntityManager em, params Object[] args) {
      var baseQuery = em.GetQuery<Customer>()
        .Where(c => c.Id == 1);
      baseQuery.Include(c => c.OrderSummaries);

      var customerResults = baseQuery.ToList();
      var includedOrders = customerResults.First().OrderSummaries.ToList();

      var customerInCache = em.FindEntities<Customer>(EntityState.AllButDetached).ToList();
      var includedOrdersInCache = em.FindEntities<OrderSummary>(EntityState.AllButDetached).ToList();
      var allEntitiesInCache = em.FindEntities(EntityState.AllButDetached).OfType<Entity>().ToList();

      if (customerResults.Count != customerInCache.Count ||
        includedOrders.Count != includedOrdersInCache.Count ||
        allEntitiesInCache.Count != (customerResults.Count + includedOrders.Count)) {

        throw new IdeaBladeException("Cache does not have the same count");

      }
      var entityCacheState = em.CacheStateManager.GetCacheState();

      return entityCacheState;
    }

Main Method

    var op = mgr.InvokeServerMethodAsync(typeName, methodName, null, null, null);
      op.Completed += (o, args) => {
        Assert.IsFalse(args.HasError, "Should not have errors");
        Assert.IsTrue(args.Result is EntityCacheState, "ECS should be returned");
        var ecs = args.Result as EntityCacheState;
        mgr.CacheStateManager.RestoreCacheState(ecs);
        mgr.Customers
          .Where(c => c.Id == 1)
          .ExecuteAsync(queryOp => {
            var anotherCust = queryOp.Results.Cast<Customer>().First();
            Assert.IsFalse(anotherCust.OrderSummaries.IsPendingEntityList, "OrderSummaries should not be pending");
            var orders = anotherCust.OrderSummaries.ToList();
          });
      };

Back to Top
tjuncewicz View Drop Down
Newbie
Newbie


Joined: 24-May-2011
Posts: 3
Post Options Post Options   Quote tjuncewicz Quote  Post ReplyReply Direct Link To This Post Posted: 26-May-2011 at 8:20am
Thanks for the response.  We are using 5.2.7.
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 26-May-2011 at 11:28am
I see. Is there any specific reason that's preventing you from upgrading to DevForce 2010?
Back to Top
tjuncewicz View Drop Down
Newbie
Newbie


Joined: 24-May-2011
Posts: 3
Post Options Post Options   Quote tjuncewicz Quote  Post ReplyReply Direct Link To This Post Posted: 03-Jun-2011 at 8:18am
Sorry for the delayed response.  Yes, there are a few reasons we haven't upgraded.  DF 2010 requires .Net 4, which requires purchase of VS2010 for all of my devs, plus a new set of licenses for our source control (which doesn't work with VS2010), plus new expression blend (we are using WPF) plus the T4 generator changed the naming for all of our navigation "ID" properties from "something_FK_something_ID" to just "somethingID" which would require overhauling a TON of XAML (we have 400+ entities and scores of screens).
 
Maybe I am mistaken in the requirements above?  We DO eventually plan on upgrading but we are already late on a project and fear this would cause even more havoc/delays..
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 03-Jun-2011 at 5:00pm
I see. Unfortunately, it sounds like you're correct on the requirements.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down