StrataFrame Forum
Back
Login
Login
Home
»
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...
Modify/update same row more than two times from BO on transaction not update it from 2nd time...
Post Reply
Like
1
Modify/update same row more than two times from BO on transaction not...
View
Flat Ascending
Flat Descending
Threaded
Options
Subscribe to topic
Print This Topic
RSS Feed
Goto Topics Forum
Author
Message
Fabian R Silva, -
Fabian R Silva, -
posted 12 Years Ago
ANSWER
Topic Details
Share Topic
Group: StrataFrame Users
Posts: 153,
Visits: 1.2K
Hello,
problem is that when loop the 2nd time, Save(lOnTr, sTrKEy) not do nothing because isDirty() is false... (1st time work ok)
how I can update a 2nd time the same table "Counter" on a transaction?
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
MyTableCounter
------------------------------
Id
|
Number
-----------------------------
1
5
2
99
3
999
dsk = "myDB"
lOnTr = true
sTrKey = "aTrKey"
BusinessLayer.TransactionBegin(dsk, trKey, IsolationLevel.ReadCommitted);
MyTableCounter.FillByPrimaryKey(1);
for(lnk=0;lnk<=5;lnk++)
{
MyTableCounter.Number += 1;
MyTableCounter.Save(lOnTr, sTrKey); --> this doesn't execute from 2nd time
AnotherTable.NewRow();
AnotherTable.MyTableCounterId = MyTableCounterId.Id;
AnotherTable.Number = MyTable.Number;
AnotherTable.Date = DateTime.Now.Date;
AnotherTable.Save(lOnTr, sTrKey);
}
MyTableCounter.FillByPrimaryKey(2);
for(lnk=0;lnk<=5;lnk++)
{
MyTableCounter.Number += 1;
MyTableCounter.Save(lOnTr, sTrKey); --> this doesn't execute
AnotherTable.NewRow();
AnotherTable.Number = MyTable.Number;
AnotherTable.Date = DateTime.Now.Date;
AnotherTable.Save(lOnTr, sTrKey);
}
BusinessLayer.TransactionCommit(dsk, sTrKey);
Tags
transactions
Reply
Like
1
Reply
Fabian R Silva, -
Fabian R Silva, -
posted 12 Years Ago
ANSWER
Post Details
Share Post
Group: StrataFrame Users
Posts: 153,
Visits: 1.2K
thanks you for the response
Today I ended up doing a process to control it "manually" before save the BO with transaction...
the resumed process that I ended up doing was;
- make a temp MyTableCounterDTO that stores info about what it have to save (using MyAnotherTable to fill it)
- fill all records that will be needed to update of MyTableCounter on 1 roundtrip (I created a base fillbyPks methods that receive an List<Int> that ended doing "select * from MyTableCounter where id in (X,Y,Z))
- 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)
- 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)
- use MyTableCounterDTO to set all the AnotherTable.Number
- Save AnotherTable (s) with MyTableCounter numbers
It worked ok but required too much work to make what I thinked that have to be a easy step.
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"
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
I will check your mentioned "trick" and will see if that work without problems. thank you so much for your response.
Reply
Like
2
GO
Merge Selected
Merge into selected topic...
Merge into merge target...
Merge into a specific topic ID...
Open Merge
Threaded View
Threaded View
Modify/update same row more than two times from BO on transaction not...
Fabian R Silva, -
-
12 Years Ago
There is a way to do this, but purists would frown upon it :) Since...
StrataFrame Team
-
12 Years Ago
Hi Ben, I am facing the same situation as described in this post....
Andrew Harper
-
9 Years Ago
thanks you for the response Today I ended up doing a process to...
Fabian R Silva, -
-
12 Years Ago
Post Reply
Like
1
Similar Topics
Post Quoted Reply
Reading This Topic
Login
Login
Remember Me
Reset Password
Resend Validation Email
Login
Explore
Messages
Mentions
Search