|  18.12.2013, 21:11 | #1 | 
| Участник | 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). | |
|  19.12.2013, 12:02 | #2 | 
| Участник | 
			
			зарепортил куда-то?
		 | 
|  | 
|  19.12.2013, 14:08 | #3 | 
| Участник | 
			
			а куда можно репортить, кроме как через New Support Request на PartnerSource? (для которого предоплата нужна)
		 | 
|  | 
|  19.12.2013, 14:24 | #4 | 
| Участник | Цитата: Но лучше конечно, когда через официальные каналы - хот фикс можете получить, да и вообще. А Саша как раз имеет возможность зарепортить, вот я и спрашиваю | 
|  | 
|  19.12.2013, 16:18 | #5 | 
| Участник | 
			
			ну баг такой не особо критичный, но интересен тем, что в дебаггере виден код, который не виден в AOT   короче я щас проверю на демо-машине последней, чтобы вам проще было воспроизвести | 
|  | 
|  19.12.2013, 16:22 | #6 | 
| Участник | 
			
			Ты уверен, что Саша это сообщение увидит? Это же блог-бот скопировал с его блога.
		 | 
|  | 
|  19.12.2013, 17:26 | #7 | 
| Участник | 
			
			Только что увидел   . Нет, еще никуда не репортил. Вообще баг странный. Такое впечатление, что на моем теперешнем клиенте это работало весь последний год (CU3), и только сейчас вылезло (CU5). В моем собственном коде, так что его пришлось срочно править. В RTM, кстати, тоже воспроизводится. Последний раз редактировалось Stitch_MS; 19.12.2013 в 17:57. | 
|  | |
| За это сообщение автора поблагодарили: kashperuk (5). | |
|  03.01.2014, 12:45 | #8 | 
| Участник | 
			
			Создал баг, посмотрим, что скажут.
		 | 
|  | |
| За это сообщение автора поблагодарили: Stitch_MS (3). | |
|  03.01.2014, 14:00 | #9 | 
| Участник | |
|  | 
|  18.01.2014, 01:50 | #10 | 
| Участник | 
			
			Вот тебе ответ на мой баг (Won't Fix): Цитата: 
		
			This is a well-know limitation due to the existing kernel implementation where only data buffer of the current table can be put in the collection list.  There are two possible work-arounds. 1. use xRecord.buf2con() and con2buf() to pack/unpack all the data buffers in the inheritance chain as container put it in the container. 2. use a class that holds the reference to the table variable, and put the class instance in the collection list. | 
|  | |
| За это сообщение автора поблагодарили: Stitch_MS (5). | |
|  21.01.2014, 18:58 | #11 | 
| Участник | 
			
			а как мне зарепортить про драгндроп?
		 
				__________________ Felix nihil admirari | 
|  | 
|  15.02.2017, 16:53 | #12 | 
| Участник | 
			
			Кстати, упаковка таким способом X++: con = [buffer]; buffer = conPeek(con, 1); [buffer] = con; Касательно использования листов и мапов мой коллега еще одну интересную особенность нашел: Если у нас есть буфер в котором есть куча длинных строковых полей (например, текстовые поля по 250-1000 символов), в которых значение пустое или записана короткая строка, то буфер в памяти занимает все запланированное место. Т.е. поле имеет длину 1000 символов, там хранится строка из 10 символов, то памяти под хранение все равно отведено 1000 символов. И это же верно при сохранении буфера в map. Поэтому если в мапах кешируем много записей у которых куча строковых полей, то они могут сожрать неожиданно много памяти. Чтобы такого не происходило, можно в мапе хранить контейнеры в которых упакованы буферы. Память существенно экономится. (Все это проверено на 2009-й аксапте. В 2012-й не перепроверяли) Последний раз редактировалось Logger; 15.02.2017 в 16:58. | 
|  |