28.10.2006, 16:40 | #1 |
Участник
|
Dynamics AX Geek: Interesting fact about set(Types::Record)
Источник: http://AxGeek.spaces.live.com/Blog/c...DB13!144.entry
============== Sets can store data of type record. By definition sets only store unique data, right? So, if you use this construct you should be aware that recId is not taken into account when determining whether a record is already in the set or not. Now, in some tables it can be perfectly normal to have records whose only difference is the recId. If you need all instances of these records in your memory storage (set) for further processing, you are better of using a different construct like a recordSortedList, recordInsertList or maybe a map. Take inventTrans for example: run the job below on your test system. If you do get a match of set elements and inventTrans records try this: Add a sales order line, any item, qty = 2. Go to the inventory transaction, functions/split and make two transactions out of one. Now run the job again. The result in my test company: 214 records in inventTrans 213 records in record set static void SetDuplicates(Args _args) { inventTrans inventTrans; set recordSet = new set(types::Record); int recordCnt = 0; ; while select inventTrans { recordSet.add(inventTrans); recordCnt++; } print strfmt("%1 records in inventTrans",recordCnt); print strfmt("%1 records in record set ",recordSet.elements()); pause; } ============== Источник: http://AxGeek.spaces.live.com/Blog/c...DB13!144.entry |
|