![]() |
#5 |
Banned
|
Кажется этой ссылки еще не было:
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.
Цитата:
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, полезное |
|
|