AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 20.06.2007, 23:13   #1  
Blog bot is offline
Blog bot
Участник
 
25,631 / 848 (80) +++++++
Регистрация: 28.10.2006
Dynamics AX: .Net BC, C# - Working with AxaptaRecord Object
Источник: http://dynamics-ax.blogspot.com/2007...ptarecord.html
==============
In moving forward with my post about working with the .Net BC and C# below is some sample code of working with an AxaptaRecord object. With this object you can call upon a DataBuffer or better known as a table variable and perform X++ SQL Statements to fill the given object with data to work with. This means that all logic, checking, validation, and methods are exposed via this object that may exist for the given DataBuffer, ie: AxaptaRecord object. Let's take a look at the code:


AxaptaRecord axRecord;
String FieldValue1;
String query;

objDAXCn = (Axapta)Session["objDAXCn"];

if (objDAXCn == null)
return "";

try
{
axRecord = objDAXCn.CreateAxaptaRecord("SomeTable");
query = "select FieldValue1 from %1 where %1.SomeKeyValue == '" + _PassedInVariable + "'";
axRecord.ExecuteStmt(query);

if (axRecord.Found)
FieldValue1 = (string)axRecord.get_Field("FieldValue1");
elseM
FieldValue1 = "";

return FieldValue1;
}
catch
{
// Do something here
}

Alright so with the above block of code what are we doing?
First we are gettting the Axapta object for our connection from a session variable. We then perform a check to see if the given object is null. If so we simply return a blank value. Here though one could re-establish the connection, report back an error, etc. The next peice to this is we call the Axapta Object.CreateAxaptaRecord() call and set our AxaptaRecord object equal to that. Notice this is done Before we call for the query to be used to fill the object with data. Next we set our Query variable equal to the select statement of choice.
Notice this is X++ SQL Statements, and notice that the %1 is used. This is because the name of the table is passed as the create of the object, and the %1 refers to said name, because the Query that is passed in is formatted internally with a strfmt() function. The next thing if we is check if a Record is found, and if so set our variable to that field value, otherwise blank it out. Very simple, but very powerful.
Here we could have created advanced DataSets that where filled, and perform for or while blocks of code used to loop through all the records found, etc. Anyway this code is very useful, and makes it possible to make use of the Business logic that may be contained at the Table object level from within the AOT. Again you can get really advanced with this, but this should give you an idea of how to work with the AxaptaRecord object.

Well please leave comments, and check back as I continue down this path in exploring with you different ways to interact with objects via the .Net BC from C#!


Find a job at: www.DynamicsAXJobs.comFind a job at: DynamicsAXJobs.com, also post a job for only $99.00!


==============
Источник: http://dynamics-ax.blogspot.com/2007...ptarecord.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
Теги
business connector

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axStart: Microsoft Dynamics AX 2009 Hot Topics Web Seminar Series Blog bot DAX Blogs 0 06.08.2008 12:05
Inside Dynamics AX 4.0: Working with the .NET Business Connector Blog bot DAX Blogs 0 04.10.2007 05:15
Dynamics AX: .Net BC Custom App, One Step Back! [Connection] Blog bot DAX Blogs 0 07.06.2007 22:41
Dynamics AX: .Net BC Custom App, Part III - Container Object Blog bot DAX Blogs 0 06.06.2007 22:11
Dynamics AX: ASP.Net and the Dynamics AX .net BC Blog bot DAX Blogs 0 05.06.2007 02:28

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 22:59.