LLBLGen 1.0.2005.1/Adapter/
I am trying to update some child entities and for some reason all of the items get set with the same value.
My code below returns a Batch and the batch items using a pretch path
var batch =
_repository.GetEntityWithPredicate<InvoiceBatchEntity>(
_batchPredicate.GetInvoiceBatchDetailsByInvoiceBatchId(model.BatchId));
Next I loop through the many items and update a property. I set the cost property (for the 3 items) to 1, 2, 3.
int i = 1;
foreach (InvoiceBatchDetailEntity entity in batch.InvoiceBatchDetails)
{
entity.Cost = i; //this should increment so my cost for 3 items should be 1,2,3
i++;
}
Checking the values I see that everything looks good. The cost property is set and the entities are dirty.
Then I call an update like so:
_repository.UpdateEntity(batch);
// the above code calls a method that looks like this:
public TEntity UpdateEntity<TEntity>(TEntity updEntity) where TEntity : IEntity2
{
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.SaveEntity(updEntity, false, true); //recurse is true
}
return updEntity;
}
The problem is that all of the items in the table after the update have a cost of 3. The update query that is used (from viewing SQL Profiler) for the detail has no predicate and it just sets all items to the last incremented from the foreach loop.
Any ideas would be appreciated on what I am doing wrong.
Thanks,
E