SIHH exhibitors member, the top watch brands in the industry with both Patek Philippe, Breguet under a high Vacheron Constantin, Audemars Piguet and Lange, and Van Cleef & Arpels and Piaget are replica watches the watchmaking and jewelry Aesthetics combined leader. On the rolex replica technical strength and the movement of manufacturing skills, few brand par with the replica watches Jaeger-LeCoultre, Parmigiani control technology to meet the people and minority tastes worldwide; Panerai and IWC as omega replica Richemont contribution classic flagship models, whether or Portugal Lumior series, table fans are replica rolex in the advanced stage of difficulty neglected works.

LINQ to Dynamics AX Entity Framework

LINQ to Dynamics AX Entity Framework saves time by avoiding to write the same code over and over again for quering data from a Dynamics AX system. The frameworks makes it possible to query and use data from Dynamics AX with the familiar LINQ syntax. The framework translates the LINQ query into a shape that AX understands. The query then is executed on the Dynamics AX system and not on the SQL server, which means that all the business logic is definetly executed as well.

To make it as easy as possible to work with the framework a user friendly GUI was created to make the settings for the framework. With this interface it is possible to specify which Dynamics AX objects should be included into the Visual Studio Project and the framework will automatically create them. The framework can create .NET objects out of AX tables, classes, enums and jobs.

The framework is written as a Visual Studio package. After installing it, it is directly embedded in Visual Studio. The code generation is creating the files directly into the Visual Studio Project, so no copy and paste is necessary any code.

Initial Screen

The initial start screen shows empty connection parameters. These parameters are used to connect to a certain Dynamics AX system. After a connection is successfully established any object from that system can be created.

Adding objects

An object can be added by typing its name into the empty textbox. The screenshot shows the InventTable, which is an important Table in Dynamics AX. The user has now the choice to decide which table fields should be added as properties to the later created entity. Furthermore method stubs could be included into the entity that later call the actual methods on the Table object in Dynamics AX.

Demonstration Video

Code Examples

The first example demonstartes how to query data from a Dynamics AX systen. After you let the framework generate your .NET entities you can directly use them with LINQ synthax. The datasource that you query against is automatically generated in the AXService class.

Simpel query
IQueryable<InventTable> qry = (from record in AXServices.InventTable select record);
AxaptaLoadOperation lo = AXServices.LoadEntities(qry);
List<Object> list = (lo.Run() as List<Object>);
this.DataGridProducts.DataContext = list;

this.ViewModel.TotalPages = (int)(lo.TotalEntityCount * 1.0 / this.ViewModel.PageSize);

This example retrieve data from more then one table in Dynamics AX by one query. With usual SQL statements as the Dynamics AX .NET business connector offers you, it's not possible to query more than one datasource at a time. As the following code shows, now it is possible by just using the LINQ join statement. The result is packed into a custom class.

Join
string itemId = selectedItem.ItemId;

IQueryable qry = (from item in AXServices.InventTable
                     where item.ItemId == itemId
                     join module in AXServices.InventTableModule
                     on item.ItemId equals module.ItemId
                     where module.ModuleType == ModuleInventPurchSales.Sales
                     select new Container() { ItemName = item.ItemName, Price = module.Price });

AxaptaLoadOperation lo = AXServices.LoadEntities(qry);
List<Object> list = (lo.Run() as List<Object>);

If you want to attach files to records in Dynamics AX, then the document handling mechanism is the right choice. We built in a mechanism to also allow you to add file attachments to entities in .NET and let the framework keep them synchronized with Dynamics AX.

File attachment
FileInfo info = new FileInfo(url);
FileStream stream = info.OpenRead();
byte[] data = new byte[stream.Length];
stream.Read(data, 0, (int)stream.Length);
stream.Close();

InventTable item = (this.DataGridProducts.SelectedItem as InventTable);
item.AddFileToDocuRef(data, info.Name, "image/" + System.IO.Path.GetExtension(info.FullName));

Each entitiy support the simple CRUD operations. You can create an new entity in .NET and with a simple call of Insert() create a record in Dynamics AX. Update and delete is supported as well.

CRUD operations
InventTable inventTableEntity = new InventTable();

inventTableEntity.ItemName = "New Item 001";
inventTableEntity.Insert();

inventTableEntity.ItemName = "Item name changed";
inventTableEntity.Update();

inventTableEntity.Delete();

Each transaction needs time for ececution. That's why it's important to only query that data that you need at the moment. We implemented a paging mechanism that gives you the information how many records are affected by your query, but only returns these, that you want to display on your current page.

Paging
this.ViewModel.PageSize = 10;

IQueryable<InventTable> qry = (from record in AXServices.InventTable orderby record.ItemId select record)
     .Skip((this.ViewModel.CurrentPage - 1) * 10).Take(this.ViewModel.PageSize);

AxaptaLoadOperation lo = AXServices.LoadEntities(qry);
this.DataGridProducts.DataContext = (lo.Run() as List<Object>);

this.ViewModel.TotalPages = (int)(lo.TotalEntityCount * 1.0 / this.ViewModel.PageSize);