Dynamics AX
  RSS Feed  LinkedIn  Twitter

Wednesday, June 06, 2007

.Net BC Custom App, Part III - Container Object

Well now we have talked a bit about design let's look into some sample C# code that works with different objects from Dynamics AX. First I want to take an object that is used a lot most likely in code, and can be very useful. That is a Container Object.

Working with an Container object from C#:

AxaptaContainer axContainer;
axContainer = (AxaptaContainer)objDAXCn.Call(StaticClassMethod"someClass","someStaticMethod",Var1,Var2,var3);

for (int i = 1; i <= axContainer.Count; i++)
{
// Preform Some code here on the returned container....
someStr = axContainer.get_Item(1).ToString();
}


Here we see exactly how to work with a Conatiner object from C#, and use a for loop call to enumerate through the container to work with the container elements. What makes the above path calls possible, is the header of the C# code contains the following:

using Microsoft.Dynamics.BusinessConnectorNet;

So we see now that if we had a static method on a class that could be coded to maybe get some data, and put that into a container object, then the above code could enumerate through that container and within C# you could work with that conatiners elements. I will continue down this path of of working with .Net BC and objects from
Dynamics AX via C#. I hope that you are enjoying this and that it helps someone out!

Check back soon!

Find a job at: www.DynamicsAXJobs.com

Labels: , , , , , , ,

1 Comments:

Blogger Huy Thieu said...

Hi,
Your post is very useful, thank you very much.
When I return a container that contains records, I have a problem is cannot get data from that container. I called :
axRecord = (AxaptaRecord)axContainer.get_Item(i);
rowDT = dt.NewRow();
rowDT["PONo"] = axRecord.get_Field("PurchId").ToString();

but it just returns "Microsoft.Dynamics.Framework.Data.Ax.DataSetViewRow"

So, my question is how can I get data from it???
Hope to receive your reply!

10:19 PM  

Post a Comment

Links to this post:

Create a Link

<< Home


Copyright 2005-2011, J. Brandon George - All rights Reserved