I am using the PerformWork event handler to pass delete/insert/update requests back to the BL from the PL (through Web Services). At first, I was thinking I could pass the UOW object - since it contains a full collection of the chnages. But, that doesn't appear to be supported - so I moved to the following basic approach:
protected void dsEmployees_PerformWork(object sender, SD.LLBLGen.Pro.ORMSupportClasses.PerformWorkEventArgs2 e)
{
EmployeeService.Employee ws = new EmployeeService.Employee();
foreach (UnitOfWorkElement2 element in e.Uow.GetEntityElementsToDelete())
{
ws.Delete(((EmployeeEntity)element.Entity).Empid);
}
foreach (UnitOfWorkElement2 element in e.Uow.GetEntityElementsToInsert())
{
ws.Update((EmployeeEntity)element.Entity);
}
foreach (UnitOfWorkElement2 element in e.Uow.GetEntityElementsToUpdate())
{
ws.Update((EmployeeEntity)element.Entity);
}
}
My question is: Is there a more elegent way that is built into LLBLGen to do this? I would like to avoid:
- repeating this block of code for every datasource
- making repetitive calls to the underlying Web Service (I'd rather one single call)
Thoughts, anyone?