Unit of Work Framework in Microsoft Dynamics AX 2012
Unit of Work Framework is use to commit number of records in a single Transaction. The main reason for introducing unit of work is that it is impossible to insert the lines table record before its header table because there is a relation between the header table and the lines table. The “Recid” of the header table is comes as a foreign key in the child table.
Let’s took an example as you can see in the Microsoft dynamics ax there are two tables i.e. MTQUnitOfWorkTable and MTQUnitOfWorkLine. These two tables are related with each other “MTQUnitOfWorkTable” is the parent table and “MTQUnitOfWorkLine” is the child table.
As you can see in the below image about these two tables and there relations.
Let’s took an example as you can see in the Microsoft dynamics ax there are two tables i.e. MTQUnitOfWorkTable and MTQUnitOfWorkLine. These two tables are related with each other “MTQUnitOfWorkTable” is the parent table and “MTQUnitOfWorkLine” is the child table.
As you can see in the below image about these two tables and there relations.
“CreateNAvigationPropertyMethods“should be set to Yes
Then create Class name as “MTQDemoClass” and then add Method, and write following piece of code.
Now Create New Job, call “demo” method.
Result: You can see that the records are crated in the child table having the id of the parent table
References:
https://msdn.microsoft.com/en-us/library/gg846338.aspx
No comments:
Post a Comment