Refetching entity collection

Posts   
 
    
Posts: 93
Joined: 13-Feb-2008
# Posted on: 24-Nov-2008 23:26:56   

I'm having an issue refetching an entitycollection.

If I add each entity in the collection to a context and fetch each individual entity (one at a time) all is well. If I try to add the whole collection to a context and refetch the sql is correct, but the entity fields are not updated.

Any tips for debugging this issue?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Nov-2008 03:45:30   

Hi Becker. Please post the code where you are testing this. Also, What DB are you using?

Also, if possible, update to the latest build version.

David Elizondo | LLBLGen Support Team
Posts: 93
Joined: 13-Feb-2008
# Posted on: 25-Nov-2008 13:51:37   

Pretty straight forward:

This works



         public void Refetch(IList<EntityBase2> payments)
         {
            if (payments != null && payments.Count() > 0)
            {
                Context context = new Context();

                using (CoreDataAccessAdapter adapter = new CoreDataAccessAdapter())
                {
                    foreach (EntityBase2 temp in payments)
                    {
                        context.Add(temp);
                        adapter.FetchEntity(temp);
                    }
                }           
            }
        }


This doesn't


private void Refetch(EntityCollection<EntityBase2> payments)
        {
        
            if (payments != null && payments.Count > 0)
            {               
                Context context = new Context();
                context.Add(payments);
                
                EntityField2 field = payments[0].Fields["PrimaryKey"] as EntityField2;

                //only fetch the entities already in the collection
                RelationPredicateBucket bucket = new RelationPredicateBucket();
                bucket.PredicateExpression.Add(field ==
                        (from IPaymentView s in payments select s.PrimaryKey).ToList<int>());

                using (CoreDataAccessAdapter adapter = new CoreDataAccessAdapter())
                {
                    adapter.FetchEntityCollection(payments, bucket);
                }
            }
        }

The sql generated for the second code block is correct, but the entity(s) are not updated. We are using sql server 2005. I don't want to have to update the llblgen libraries as I am using a custom build and don't have the hours available to re-factor...

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-Nov-2008 07:54:01   

I can't reproduce your problem disappointed

Are you using a custom build of LLBLGen ORMSupportClasses? You don't need to update to v2.6, just update to the latest build of v2.5. I see some fixes on the Context behavior for v2.5 at ChangeLog history, so, update could be wise.

David Elizondo | LLBLGen Support Team