Показать сообщение отдельно
Старый 02.03.2012, 01:18   #1  
Blog bot is offline
Blog bot
Участник
 
25,646 / 848 (80) +++++++
Регистрация: 28.10.2006
How to make a temporary instance of a database table to be shown on the form
Источник: http://alexvoy.blogspot.com/2012/03/...stance-of.html
==============

This short code shows how to work with a temporary table without creating it in AOT.

X++:
// how to use temporary table
// method Init of the form
public void init()
{
    WmpInventNutrition        nut; // regular table in AOT
    WmpInventNutrition        tmp; // instead of creating in AOT a temporary table
                                   // we can create a temporary instance of the preivous regular table
    ;
     super();

    // here we make it temporary;
    // it will disappear from memory when loses the scope
    // in other words, when we close the form
    tmp.setTmp();

    // simply selecting some of records from the regular table
    while select nut
        where nut.ItemId like '_wmp*'
    {
        // and putting them in the temporary one
        tmp.data(nut);
        tmp.doInsert();
    }
    // finally to show them on the form
    // we set the form data source to the temporary table
    wmpInventNutrition.setTmp();
    wmpInventNutrition.setTmpData(tmp);
}


Alternatively, if you know exactly how the field match, it will be faster to use insert_recordset:


X++:
 // simply selecting some of records from the regular table
    tmp.skipDataMethods();
    insert_recordSet tmp (itemid) select ItemId from nut where nut.ItemId like '_wmp*';

Источник: http://alexvoy.blogspot.com/2012/03/...stance-of.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.

Последний раз редактировалось Poleax; 02.03.2012 в 10:47. Причина: оформление