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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 23.01.2017, 16:53   #5  
ax_mct is offline
ax_mct
Banned
 
2,548 / 1091 (0) ++++++++
Регистрация: 10.10.2005
Адрес: Westlands
Кажется этой ссылки еще не было:
https://blogs.msdn.microsoft.com/sav...series-part-5/
Цитата:
Although the number of insert calls remain 20k, the time fall down from 5 seconds to 1.5 seconds. Now we are more than 3 times faster than the naïve approach that calls the insert statement 20k times through a loop.
Цитата:
  • UnitOfWork must run on the server tie
  • The child must have a relation explicity defined in AOT to the parent
  • No record will be inserted into the database until the saveChanges method is called.
  • You can enjoy the methods: insertOnSaveChanges, deleteOnSaveChanges, updateOnSaveChanges, saveChanges
Фича, да. Но я бы не применял по умолчанию пока не поставлена отдельная задача по улучшению производительности и тогда рассматривал бы как одну из опций. Так как какие-то риски все равно есть, а в первоначальных решений их надо сводить к минимуму.

X++:
public static server void insertWithUnitOfWork()
{
    FooChild   child;
    FooParent  parent;

    // Instantiating the UnitOfWork.
    // Notice that this method runs on server
    UnitofWork unitOfWork = new unitOfWork();
    int i;

    for (i = 0; i < 10000; ++i)
    {
        parent.ParentId = int2str(i);
        parent.Name = 'Any name for parent' + int2str(i);
        parent.Description = 'Any description for parent' + int2str(i);

        child.ChildId = int2str(i);
        child.Name = 'Any name for child' + int2str(i);
        child.Description = 'Any description for child' + int2str(i);

        // You will just be able to call this method if there is a relation
        // called FooParent at FooChild table
        child.FooParent(parent);

        // Marking these buffers to be inserted by UnitOfWork
        // The buffers are not being inserted at the database right now.
        unitOfWork.insertonSaveChanges(parent);
        unitOfWork.insertonSaveChanges(child);
    }

    // Finally, asking UnitOfWork to insert the records at the database.
    unitOfWork.saveChanges();
}
За это сообщение автора поблагодарили: mazzy (2).
Теги
unitofwork, полезное

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axmfg: Rounding up work for raw material picking to the nearest handling unit Blog bot DAX Blogs 0 20.01.2016 22:13
DynamicsAxSCM: WHS Work List Blog bot DAX Blogs 0 19.06.2015 15:11
DynamicsAxSCM: How to support a case picking operation using wave containerization in AX2012R3 Blog bot DAX Blogs 0 19.11.2014 16:11
axmfg: Replacing work order types for production output in CU8 Blog bot DAX Blogs 0 12.09.2014 18:12
axdaily: Unit of Work Blog bot DAX Blogs 4 05.05.2011 11:54

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

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

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