It has four fields: Note that it’s important for the table to have a primary key, otherwise we wouldn’t be able to update the data. We’ll need a table storing the data and because the Now start Visual Studio, because most of our work will happen there.
Create a new C# class library, add it to AOT and drag the table and the enum from Application Explorer to your project. Open Server Explorer and create a connection to your database.
Although the core idea can be used in AX from version 4.0, this blog post uses AX 2012 and depends on several features that don’t exist in older version.
First of all, look at how you’re supposed to construct the query for Odbc Connection: (This is taken from the sample code on MSDN.) You have to define the query as a simple string, therefore you have to write SQL code by yourself, you won’t get any Intelli Sense, compile-type control or anything like that.
I’m using a SQL Server database on the current machine, but you can use ODBC, connect to remote servers or anything you need.
Now you should see your tables directly in Server Explorer in Visual Studio: Right-click your project in Solution Explorer, choose .
For example, notice that the query above selects all fields. It’s simply unpleasant for development and horrible for maintenance.Wouldn’t it be better if we could simply refer to field as if we do in normal X++ development, get compile-type control and so on? Before we actually start, let me show you the table that will simulate my external data.