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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 28.01.2011, 23:14   #1  
Blog bot is offline
Blog bot
Участник
 
25,631 / 848 (80) +++++++
Регистрация: 28.10.2006
axzaptech: RecordSortedList and RecordInsertList
Источник: http://axzaptech.wordpress.com/2010/...ordinsertlist/
==============

For those who are wondering, Is there any way in AX to reduce the client server call when inserting a bunch of records into the database. With no surprise Yes!, AX provides a way to do that. Two Collection classes are there in AX RecordSortedList and RecordInsertList for this purpose.

The RecordSortedList class inserts multiple records in a single database trip, and can hold a subset of data from a table, in a particular sort order that does not exist as an index. There are built-in methods in RecordSortedList which can be used to perform the insertion to database. You must provide the sort order in order to perform the insertion properly. The following code sample demonstrates how to insert multiple Student records in the same database trip, using RecordSortedList:

 
X++:
Student student;
RecordSortedList recordSortedList = new RecordSortedList(tablenum(Student));
recordSortedList .sortOrder(fieldname2id(tablenum(Student),));

student.clear();
student.StudentID=;
student.FirstName=;
student.LastName=;
recordSortedList.ins(student);

student.clear();
student.StudentID=;
student.FirstName=;
student.LastName=;
recordSortedList.ins(student);

student.clear();
student.StudentID=;
student.FirstName=;
student.LastName=;
recordSortedList.ins(student);

recordSortedList.insertDatabase();
 
 

The RecordInsertList class provides array insert capabilities in the kernel. This allows you to insert more than one record into the database at a time, which reduces communication between the application and the database.

RecordInsertList is similar to RecordSortedList, but it has built-in client/server support (it automatically packs data from one tier to another when needed), and it lacks the sort order features available in RecordSortedList.

 
The following is an example using RecordInsertList

X++:
Student student;
RecordInsertList insertList = new RecordInsertList(student.TableId, True);
int i;

for ( i = 1; i <= 100; i++ )
{
student.StudentrId = +int2str(i);
insertList.add(student);
}

insertList.insertDatabase();
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axStart: RecordSortedList Blog bot DAX Blogs 0 21.12.2007 04:11

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

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

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