05.05.2011, 00:11 | #1 |
Участник
|
axdaily: Unit of Work
Источник: http://axdaily.blogspot.com/2011/05/unit-of-work.html
============== After the post about surrogate keys I was asked the following question: There is the following problem with using surrogate keys. A record gets RecId value at the moment it is inserted into the database. What if we are doing bulk insert of a journal with many lines and the journal header contains some totals calculated based on its lines. It is impossible to insert lines before header since the value of the journal's surrogate key is unknown. But that would be so convenient because otherwise the header should be inserted first, then the lines and then the header should be updated with the calculated totals. The answer is – use Unit of Work. It allows to perform create, update and delete operations without worrying about the order of those and without a need to specify surrogate key values. It will all be done automatically in the kernel! Example: Let we have the following tables: The following job will insert the journal header with calculated totals and 10 lines. Note, that there is no place where surrogate keys are mentioned in the code. Business data only. And here is the result. Some more details about the unit of work feature:
Источник: http://axdaily.blogspot.com/2011/05/unit-of-work.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|