Thursday 6 December 2012

Unit Of Work Implementation in Dynamics AX


UNIT OF WORK:

Unit of work keeps track of everything you do during a transaction that can effect the database. It keeps track of everything that needs to be done to alter the database as a result of your work.

There is a system class called UnitOfWork Class in X++ that implements the Unit Of Work Framework. Some of it's details are given below.

Clear
 Clears all the changes
DeleteonSaveChanges
 Deletes the record on commit/save changes
InsertOnSaveChanges
 Inserts the record on commit /save changes
UpdateOnSaveChanges
 Updates the record on commit /save changes
SaveChanges
 Save the changes on the server

Implementing the Unit Of Work:

In this example we will perform bulk insertion on tables , this is where the role of Unit of work comes into play . By means of it we can insert lines against a header record without creating the header first on the basis of the Rec Id that comes as a foreign key in the child table.

Example:


In this example you can see we have created two tables :
  • Candidate 
  • Exam
Where the Exam table behaves as the header table and the Candidate tables acts as the Lines.The Screen shot below shows the relation between them.


After this step we need to set the CreateNavigationPropertyMethods Property to Yes.  As Shown in the screen shot below.


After that we need to create a new class and add a Method in it that will perform all the calculations and insertions , as shown in the screen shot below.



 Finally we need to call this method in a job. The results can be seen by opening the tables.



In this way the DataSources can be grouped as a unit of work and Ax Client has great support for it.

I believe it was helpful.  


1 comments:

quigleyquaranto said...

Casino game software - DRMCD
Find the best casinos that have 목포 출장샵 the best slots. 강릉 출장안마 We will look at the latest 남원 출장마사지 slots in our collection and see 세종특별자치 출장마사지 if you like the 제주도 출장샵 games, Jan 7, 2019 · Uploaded by Slots-Casinos

Post a Comment