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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 18.12.2013, 21:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
sashanazarov: Table inheritance and collection objects
Источник: http://sashanazarov.blogspot.com/201...n-objects.html
==============


Be aware that there is an issue with storing child table records in collection objects like List.

If you have a table hierarchy and add a child table record to a List and then try to get it back, information from parent tables is lost, along with InstanceRelationType field value.

The following job reproes the issue:

static void tableInheritanceAndListBug(Args _args)
{
CompanyInfo companyInfo;
List companyInfoList;
ListEnumerator companyInfoEnumerator;

companyInfoList = new List(Types::Record);

select firstOnly companyInfo;

info(strFmt(
"Orig: RecId: %1, Name: %2, InstanceRelationType: %3",
companyInfo.RecId,
companyInfo.Name,
companyInfo.InstanceRelationType));

companyInfoList.addEnd(companyInfo);

companyInfoEnumerator = companyInfoList.getEnumerator();
if (companyInfoEnumerator.moveNext())
{
companyInfo = companyInfoEnumerator.current();
info(strFmt(
"List: RecId: %1, Name: %2, InstanceRelationType: %3",
companyInfo.RecId,
companyInfo.Name,
companyInfo.InstanceRelationType));
}
}
Output:
Orig: RecId: 5637151316, Name: Contoso Entertainment Systems - E&G Division, InstanceRelationType: 41
List: RecId: 5637151316, Name: , InstanceRelationType: 0

The workaround is to use buf2con function to convert the table buffer to a container, save the container in the list and finally use con2buf when fetching the value with enumerator.

static void tableInheritanceAndListBugWorkaround(Args _args)
{
CompanyInfo companyInfo;
List companyInfoList;
ListEnumerator companyInfoEnumerator;

companyInfoList = new List(Types::Container);

select firstOnly companyInfo;

info(strFmt(
"Orig: RecId: %1, Name: %2, InstanceRelationType: %3",
companyInfo.RecId,
companyInfo.Name,
companyInfo.InstanceRelationType));

companyInfoList.addEnd(buf2Con(companyInfo));

companyInfoEnumerator = companyInfoList.getEnumerator();
if (companyInfoEnumerator.moveNext())
{
companyInfo = con2Buf(companyInfoEnumerator.current());
info(strFmt(
"List: RecId: %1, Name: %2, InstanceRelationType: %3",
companyInfo.RecId,
companyInfo.Name,
companyInfo.InstanceRelationType));
}
}
Output:
Orig: RecId: 5637151316, Name: Contoso Entertainment Systems - E&G Division, InstanceRelationType: 41
List: RecId: 5637151316, Name: Contoso Entertainment Systems - E&G Division, InstanceRelationType: 41


Источник: http://sashanazarov.blogspot.com/201...n-objects.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
За это сообщение автора поблагодарили: gl00mie (5).
Теги
buf2con, con2buf

 


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

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

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