﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Modify/update same row more than two times from BO on transaction not update it from 2nd time hereinafter</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 19 May 2026 22:02:22 GMT</lastBuildDate><ttl>20</ttl><item><title>Modify/update same row more than two times from BO on transaction not update it from 2nd time hereinafter</title><link>http://forum.strataframe.net/FindPost31946.aspx</link><description>&lt;div&gt;Hello,&amp;nbsp;&lt;div&gt;&lt;div&gt;problem is that when loop the 2nd time, Save(lOnTr, sTrKEy) not do nothing because isDirty() is false... (1st time work ok)&lt;br/&gt;&lt;br/&gt;&lt;div&gt;how I can update a 2nd time the same table "Counter" on a transaction?&lt;div&gt;I need this because this will lock the number on MyTabkecounter an allow to use it in AnotherTable on a transaction without fear of that this number can be repeated&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;MyTableCounter&lt;div&gt;------------------------------&lt;div&gt;Id&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;|&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;Number&lt;div&gt;-----------------------------&lt;div&gt;1&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;5&lt;div&gt;2&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;99&lt;div&gt;3&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;999&lt;br/&gt;&lt;br/&gt;&lt;div&gt;dsk = "myDB"&lt;div&gt;lOnTr = true&lt;div&gt;sTrKey = "aTrKey"&lt;br/&gt;&lt;br/&gt;&lt;div&gt;BusinessLayer.TransactionBegin(dsk, trKey, IsolationLevel.ReadCommitted);&lt;div&gt;MyTableCounter.FillByPrimaryKey(1);&lt;div&gt;for(lnk=0;lnk&amp;lt;=5;lnk++)&lt;div&gt;{&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;MyTableCounter.Number += 1;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;MyTableCounter.Save(lOnTr, sTrKey); --&amp;gt; this doesn't execute from 2nd time&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;AnotherTable.NewRow();&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AnotherTable.MyTableCounterId = MyTableCounterId.Id;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;AnotherTable.Number = MyTable.Number;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;AnotherTable.Date = DateTime.Now.Date;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;AnotherTable.Save(lOnTr, sTrKey);&lt;div&gt;}&lt;br/&gt;&lt;br/&gt;&lt;div&gt;MyTableCounter.FillByPrimaryKey(2);&lt;div&gt;for(lnk=0;lnk&amp;lt;=5;lnk++)&lt;div&gt;{&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;MyTableCounter.Number += 1;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;MyTableCounter.Save(lOnTr, sTrKey); --&amp;gt; this doesn't execute&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;AnotherTable.NewRow();&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;AnotherTable.Number = MyTable.Number;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;AnotherTable.Date = DateTime.Now.Date;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;AnotherTable.Save(lOnTr, sTrKey);&lt;div&gt;}&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;BusinessLayer.TransactionCommit(dsk, sTrKey);</description><pubDate>Fri, 01 Jul 2016 02:33:48 GMT</pubDate><dc:creator>Fabian R Silva, -</dc:creator></item><item><title>RE: Modify/update same row more than two times from BO on transaction not update it from 2nd time hereinafter</title><link>http://forum.strataframe.net/FindPost33326.aspx</link><description>Hi Ben,&lt;br/&gt;&lt;br/&gt;&lt;div&gt;I am facing the same situation as described in this post.&lt;br/&gt;&lt;br/&gt;&lt;div&gt;Within &amp;nbsp;a transaction I do the following&lt;br/&gt;&lt;br/&gt;&lt;div&gt;1. Save BoOrderMaster to insert a new OrderMaster record with a boOrderMaster.Status ='T'&amp;nbsp;&lt;div&gt;2. Save BoOrderLines to insert the orderlines&lt;div&gt;3. Set &amp;nbsp;boOrderMaster.Status ='U'&lt;div&gt;4. Save BoOrderMaster&lt;div&gt;5. commit&amp;nbsp;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;Step 4 is not updating the database&lt;br/&gt;&lt;br/&gt;&lt;div&gt;As per your previous suggestion I have tried the inserting following code prior to Step 4&amp;nbsp;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;[code]&lt;/span&gt;&lt;div&gt;Dim isSavedOnTransactionField As FieldInfo&lt;br/&gt;&lt;div&gt;&lt;span&gt;isSavedOnTransactionField = boOrderMaster.GetType().GetField("_IsSavedOnTransaction", BindingFlags.NonPublic Or BindingFlags.Instance)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;div&gt;&lt;span&gt;isSavedOnTransactionField.SetValue(boOrderMaster, False) &amp;nbsp;&lt;/span&gt;&lt;div&gt;&lt;span&gt;[/code]&lt;/span&gt;&lt;div&gt;&lt;span&gt;&lt;br/&gt;&lt;/span&gt;&lt;div&gt;&lt;span&gt;The &amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;strong&gt;isSavedOnTransactionField.SetValue(boOrderMaster, False)&lt;/strong&gt; statement throws an error.&lt;br/&gt;&lt;br/&gt;&lt;div&gt;I have been able to get around the problem in this instance by performing steps 3 and 4 after the commit but am wondering if am missing something here and/or if the suggested work around using reflection is still valid and has been tested.&lt;br/&gt;&lt;br/&gt;&lt;div&gt;TIA Andy&amp;nbsp;</description><pubDate>Fri, 01 Jul 2016 02:33:48 GMT</pubDate><dc:creator>Andrew Harper</dc:creator></item><item><title>RE: Modify/update same row more than two times from BO on transaction not update it from 2nd time hereinafter</title><link>http://forum.strataframe.net/FindPost31949.aspx</link><description>thanks you for the response&lt;br/&gt;&lt;br/&gt;&lt;div&gt;Today I ended up doing a process to control it "manually" before save the BO with transaction...&amp;nbsp;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;the resumed process that I ended up doing was;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;- make a temp MyTableCounterDTO that stores info about what it have to save (using MyAnotherTable to fill it)&lt;div&gt;- fill all records that will be needed to update of MyTableCounter on 1 roundtrip (I created a base fillbyPks methods that receive an List&amp;lt;Int&amp;gt; that ended doing "select * from MyTableCounter where id in (X,Y,Z))&lt;div&gt;- store on MyTablecounterDTO LastNumber = MyTableCounter.Number, and a "RequiredNumbers" that stores how much times it need to be increased (in the example increase Number 5 times for id 1 and 2, then I fill those two Pks)&lt;div&gt;- increase number of id on all neded records from MyTableCounter (1 and 2 in this case with number+5) and save it (it locks each row on MyTableCounter)&lt;div&gt;- use MyTableCounterDTO to set all the AnotherTable.Number&lt;div&gt;- Save AnotherTable (s) with MyTableCounter numbers&lt;br/&gt;&lt;br/&gt;&lt;div&gt;It worked ok but required too much work to make what I thinked that have to be a easy step.&lt;br/&gt;&lt;br/&gt;&lt;div&gt;I not sure if saving a 2nd time the same row/record from same bo and transaction is allowed by sql server on isolation level "read commited"&lt;div&gt;I thinked that it was the normal behavior of Strataframe when save on transaction that if I save a bo, change it and save again it have to save&lt;br/&gt;&lt;br/&gt;&lt;div&gt;I will check your mentioned "trick" and will see if that work without problems. thank you so much for your response.</description><pubDate>Fri, 22 Mar 2013 13:07:49 GMT</pubDate><dc:creator>Fabian R Silva, -</dc:creator></item><item><title>RE: Modify/update same row more than two times from BO on transaction not update it from 2nd time hereinafter</title><link>http://forum.strataframe.net/FindPost31948.aspx</link><description>There is a way to do this, but purists would frown upon it :) &amp;nbsp;Since you're saving the same record over and over again instead of creating a new record, we need to tell the MyTableCounter business object that it isn't really "saved." &amp;nbsp;The flag that is preventing it from saving after the first time is an internal field called _IsSavedOnTransaction. &amp;nbsp;You need to use Reflection to set that field back to False each time before you try to save the MyTableCounter business object. &amp;nbsp;I say purists would hate it because they say you should never tamper with something using Reflection. &amp;nbsp;In this case, it works just fine.&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;using System.Reflection;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;...&lt;br/&gt;&lt;br/&gt;&lt;div&gt;//-- Get a reference to the FieldInfo of the field we need to set&lt;div&gt;FieldInfo isSavedOnTransactionField = MyTableCounter.GetType().GetField("_IsSavedOnTransaction", BindingFlags.NonPublic | BindingFlags.Instance);&lt;br/&gt;&lt;br/&gt;&lt;div&gt;...&lt;br/&gt;&lt;br/&gt;&lt;div&gt;//-- In your loop before you save the BO&lt;div&gt;isSavedOnTransactionField.SetValue(MyTableCounter, false);</description><pubDate>Fri, 22 Mar 2013 09:23:44 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>