Join first line in AX 2012

You sometimes need to join only one related record for each parent record, for example one order line for each order header. I’m always suspicious of such requirements, because it often means that users/analysts didn’t realize that there may be more than one record, or they didn’t think enough of identifying the one record they …

Continue reading ‘Join first line in AX 2012’ »

Connection string for LINQ to SQL

In my article about connecting to external databases with the help of LINQ to SQL, I already mentioned how to parametrize which database to use, because you’ll likely use different databases for development, test and live environments. I wrote: In real implementations, I usually store DB server and DB name in AX database, create a …

Continue reading ‘Connection string for LINQ to SQL’ »

Connection to external database

You sometimes need to connect from Dynamics AX to another database and read or write data there. The usual approach uses OdbcConnection class, as described on MSDN in How to: Connect to an External Database from X++ Code [AX 2012]. Although it definitely is a possible solution (I used it already in AX 3.0), it …

Continue reading ‘Connection to external database’ »

Queries to tables with inheritance

Table inheritance is an interesting feature of Dynamics AX 2012 allowing to model type hierarchies in database in a way similar to object modeling. Dynamics AX allows not only to define inheritance in metadata, but it also takes it automatically into account in queries to database, in forms and so on. The problem is that …

Continue reading ‘Queries to tables with inheritance’ »

AX2012: Subqueries in views

Dynamics AX 2012 supports computed columns in AOT views. That allows you to convert a value of a field in some way, to actually compute a value based on several fields and so on, and it’s all defined directly in SQL Server as any other view. Indeed, the definition of a computed column just generates …

Continue reading ‘AX2012: Subqueries in views’ »