Applications Server
 

Microsoft Dynamics AX 2009 : Design and Implementation Patterns (part 2) - Table-Level Patterns

11/22/2011 3:01:07 PM

Table-Level Patterns

The patterns described in this section—the Find and Exists methods, polymorphic associations (Table/Group/All), and Generic Record References—apply to tables.

Find and Exists Methods

Each table must have the two static methods Find and Exists. They both take the table’s primary keys as parameters and return the matching record or a Boolean value, respectively. Besides the primary keys, the Find method also takes a Boolean parameter that specifies whether the record should be selected for update.

For the CustTable table, these methods have the following profiles.

static CustTable find(CustAccount accountNum, boolean _forUpdate = false)
static boolean exist(CustAccount accountNum)


Polymorphic Associations

The Table/Group/All pattern is used to model a polymorphic association to either a specific record in another table, a collection of records in another table, or all records in another table. For example, a record could be associated with a specific item, all items in an item group, or all items.

You implemented the Table/Group/All pattern by creating two fields and two relations on the table. By convention, the first field’s name has the suffix Code, as in ItemCode. This field is modeled using the enum TableGroupAll. The second field’s name usually has the suffix Relation, for example, ItemRelation. This field is modeled using the extended data type that is the primary key in the foreign tables. The two relations are both of the type Fixed field relation. The first relation specifies that when the Code field equals 0 (TableGroupAll::Table), the Relation field equals the primary key in the foreign master data table. The second relation specifies that when the Code field equals 1 (TableGroupAll::Group), the Relation field equals the primary key in the foreign grouping table.

Figure 1 shows an example.

Figure 1. A polymorphic association


Generic Record Reference

The Generic Record Reference pattern is a variation of the Table/Group/All pattern. It is used to model an association to a foreign table. It comes in three flavors: (a) an association to any record in one specific table, (b) an association to any record in a fixed set of specific tables, and (c) an association to any record in any table.

All three flavors of this pattern are implemented by creating a field using the RefRecId extended data type.

To model an association to any record in one specific table (flavor a), a relation is created from the RefRecId field to the foreign table’s RecId field, as illustrated in Figure 2.

Figure 2. An association to one specific table


For flavors b and c, an additional field is required. This field is created using the RefTableId extended data type. To model an association to any record in a fixed set of specific tables (flavor b), a relation is created for each specific foreign table from the RefTableId field to the foreign table’s TableId field, and from the RefRecId field to the foreign table’s RecId field, like shown in Figure 3.

Figure 3. A association to any record in a fixed set of tables


To model an association to any record in any table (flavor c), a relation is created from the RefTableId field to the generic table Common TableId field and from the RefRecId field to Common RecId field, as shown in Figure 4.

Figure 4. An association to any record in any table

 
Others
 
- Microsoft Dynamics AX 2009 : Design and Implementation Patterns (part 1) - Class-Level Patterns
- BizTalk 2009 : Creating More Complex Pipeline Components (part 4) - Custom Disassemblers
- BizTalk 2009 : Creating More Complex Pipeline Components (part 3) - Validating and Storing Properties in the Designer
- BizTalk 2009 : Creating More Complex Pipeline Components (part 2) - Schema Selection in VS .NET Designer
- BizTalk 2009 : Creating More Complex Pipeline Components (part 1) - Dynamically Promoting Properties and Manipulating the Message Context
- Microsoft Dynamics GP 2010 : Tailoring SmartLists by adding Fields
- Microsoft Dynamics GP 2010 : Controlling data with SmartList Record Limits
- Upgrading and Configuring SharePoint 2010 : Configuring a content database
- Upgrading and Configuring SharePoint 2010 : Creating and associating content databases to a specific web application and site collection
- Administering Active Directory Domain Services : Working with Active Directory Snap-ins (part 2) - Saving and Distributing a Custom Console
- Administering Active Directory Domain Services : Working with Active Directory Snap-ins (part 1)
- Microsoft Dynamic CRM 2011 : Canceling and Reopening a Service Request Case
- Microsoft Dynamic CRM 2011 : Resolving a Service Request Case
- Systems Management Server 2003 : Server Modifications After Installation
- Systems Management Server 2003 : Modifying the Installation
- Creating a SharePoint Form with InfoPath Designer : Create a Form Library from InfoPath & Design a SharePoint Form Using the SharePoint Form Library Template
- Creating a SharePoint Form with InfoPath Designer : Publish Your Form & Use Your Form in SharePoint
- Microsoft Dynamics AX 2009 : Code Access Security
- Microsoft Dynamics AX 2009 : Classes and Interfaces
- Determining Exchange Server 2007 Placement
 
 
Most View
 
- Adobe Flash Professional CS5 : Manipulating Symbols in 3D Space (part 1) - Controlling the camera view: Perspective and vanishing point
- Adobe Flash Professional CS5 : Manipulating Symbols in 3D Space (part 2) - Transforming symbols with the 3D Rotation tool
- Mobile Web Apps : Loading Pages (part 3) - Going Backwards
- Microsoft Dynamics AX 2009 : Design and Implementation Patterns (part 1) - Class-Level Patterns
- Introducing the iPhone SDK (part 5) - Programming Paradigms
- Beginning Android 3 : Set Up the Emulator
- Microsoft Excel 2010 : Analyzing Worksheet Data - Adding Data Validation to a Worksheet
- Microsoft Dynamic CRM 2011 : Resolving a Service Request Case
- Accessing PowerPoint on the Web and Mobile Devices (part 1) - Setting Up SkyDrive
- Microsoft Excel 2010 : Using Print Preview