General information
Category:
The Mere Mortals .NET Framework
Title:
Concurrency Error when repeatedly saving field
This is really odd. I'm writing some tests where I change data (SQL Express), run the test, verify the results, change the data, repeat...
I get a concurrency error half the time I run the test. I'm using NUnit and the failure is the same if I run it in Visual Studio.
Here's the code that causes a problem:
BidsItems oBidsItem = new BidsItems();
.
.
.
// Retrieve data with BidFK = oBid.Entity.BidPK
oBidsItem.GetDataByFK("BidFK", oBid.Entity.BidPK);
.
.
.
oBidsItem.Entity.UnitPrice = 2.25M;
if (oBidsItem.SaveRow() != mmSaveDataResult.RulesPassed)
{
Console.WriteLine("BidsItem.SaveRow() Failed #1");
}
oBidsItem.Entity.UnitPrice = 2.75M;
if (oBidsItem.SaveRow() != mmSaveDataResult.RulesPassed)
{
Console.WriteLine("BidItem.SaveRow() Failed #2");
}
Obviously there was code between the saving of the business object, but I found that the problem was the same without any intervening code. Every other time I run the test, I get a 'Failed #2' message. Since I'm running through NUnit, there should be exactly 0 persistent objects.
If I change the second test column from UnitPrice to something else, it works fine. If I add a line to reload the business object before I change the UnitPrice to 2.75, it works fine. It's almost like the first change does not make it's way though the system.
Thanks for your help,
Jeff
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only