LLBLGen 2.0.7.424 / ASP.net 2 / Adapter
Hi
I have a LLBLGen datasource bound to a data grid. The code is the following:
protected void qualificationDataSource_PerformSelect(object sender, PerformSelectEventArgs2 e) {
qualificationDataSource.EntityCollection = Employee.EmployeeQualification;
}
protected void qualificationDataSource_PerformWork(object sender, PerformWorkEventArgs2 e) {
// loop through entities to update
foreach(UnitOfWorkElement2 element in e.Uow.GetEntityElementsToUpdate()) {
// find entity to update in collection
EmployeeQualificationEntity item = (EmployeeQualificationEntity)element.Entity;
List<int> list = Employee.EmployeeQualification.FindMatches(EmployeeQualificationFields.Id == item.Id);
// exchange entity with new version
int index = list[0];
Employee.EmployeeQualification[index] = item;
}
}
public EmployeeEntity Employee {
get { return (EmployeeEntity)((IParentDialogPage)Page).Entity; }
}
(the example does not support add or delete items. I just wanna focus on update.)
This code works fine when using the standard MS datagrid. In my case I use the Infragistics one. The main difference is that with the Infragistics grid I can edit several rows on client side and send all changes to the client in one go.
I would expect that the UnitOfWork object contains just all the updated objects. In reality PerformWork is called as much times as I changed rows. So when I change 3 rows PerformWork is called 3 times! The first time the UOW object contains 1 item, the second time 2 and when PerformWork is called for the last time it contains 3 items. Isn't that funny?
Additionally, in the last call of PerformWork the above standing code throws an error because one of the entity contained in UOW is not in the collection anymore (Employee.EmployeeQualification).
How can I resolve that? Can somebody confirm that behaviour?
Additional hints:
- I asked a similar question some days ago and somebody wrote that PerformSelect resets the datasource. Because my collection is referenced (Employee.EmployeeQualification) it would be set to null too. Walaa then wrote that the datasource.collection is not reset and always contains values. I can confirm that as my code works with the MS grid.
- ViewState is enabled in all controls.