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...