28.01.2011, 23:14 | #1 |
Участник
|
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, напишите личное сообщение администратору. |
|