Hi,
I have a table with Projects. In this table Projects can be related to eachother. For example: An Internal project can be related to multiple external project. This information is stored on the external project and it uses a column InternalProjectID for this. This column is NULL of course for an internal project.
I now have a function in the business layer. This function has as parameters a UnitOfWork and an array.
The UnitOfWork contains a new project that has to be inserted/updated. It's a unitofwork because a lot of extra data also related to the project is inserted at the same time.
The problem lies with new projects. These new projects do not have a projectID, it's autoidentity and retrieved after the insert/update from the unitofwork using the refetch parameter. But in the business layer I already need this new projectID to update all the projects of which the projectID is on the array, setting the InternalProjectID to this new id. And this all must be done in the same transaction.
Code I have so far:
DataAccessAdapter adapter = new DataAccessAdapter();
adapter.StartTransaction(IsolationLevel.ReadCommitted, "ProjectSave");
// then some delete stuff first
uow.Commit(adapter);
//In here I need to insert/update the other projects
adapter.Commit();
There's only one ProjectEntity in the uow and uses recursive to save all the other related data, so only this line is used:
uow.AddForSave(currentProject, null, true, true);
Can someone tell me how I can retrieve the project id between the uow.Commit and the insert/update of the other projects?
Thank you very much,