Background Info:
Designer: Version 2.0.0.0 Final, March 21st, 2007
Runtime: SD.LLBLGen.Pro.DQE.SqlServer.NET20.dll - 2.0.07.0129, SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll - 2.0.07.0424
.Net 2.0, Self Servicing General, C#
SQL Server 2005
I have a question regarding how transactions are used in self servicing when the entities are fetched via a collection.
We ran into an issue where we fetch an entity collection in a transaction, dispose of the transaction, and then the entities in that collection still reference the transaction that was used to fetch them. This has led to some unexpected behavior where the fetched entity is saved in the wrong transaction which creates a deadlock.
Should the entities in a collection still have a reference to the collection's transaction? Other than looping through the collection and setting each entity's Transaction property to null, is there a way to clear the entity's transaction?
Here's a NUnit test which demonostrates "the problem." The test fails on the last Assert.
[NUnit.Framework.Test]
public void LLBLGenTransactionTest()
{
AddressCollection addresses = new AddressCollection();
using (Transaction tran = new Transaction(System.Data.IsolationLevel.ReadCommitted, "test"))
{
addresses.Transaction = tran;
addresses.GetMulti(null, 10);
addresses.Transaction = null;
}
Assert.IsNull(addresses.Transaction);
Assert.Greater(addresses.Count, 0);
foreach (AddressEntity address in addresses)
Assert.IsNull(address.Transaction);
}
Does 2.5 in self servicing function in the same manner? (I don't have a 2.5 project I can test it with.)
Thanks,
-Ryan Casey