If you use DataProviderEnterprise as the provider class are you required to use System.Transactions.TransactionScope when setting up a transaction block? If you don't and you use esTransactionScope, EntitySpaces seems to ignore it.
We're on EntitySpaces 1.5.3 using Sql Server 2005 and Asp.Net 2.0.
We have a mix of legacy objects and functions that do not use EntitySpaces and some that do. When using them together, I was under the impression that we would need EntitySpaces to use the System.Transactions.TransactionScope class rather than the built in transaction scope class so that all of the objects would be saved under one transaction. I thought that by setting the providerClass in web.config to DataProviderEnterprise that EntitySpaces would use the TransactionScope class under the hood rather than the one that mimics the TransactionScope class. A test below shows that's not quite the case.
Test 1: providerClass="DataProviderEnterprise" - save is not rolled back
using (esTransactionScope scope = new esTransactionScope())
{
...
esItem.Save(); // EntitySpace object
// esItem save should be rolled back
throw new Exception("Test Transaction Exception");
}
What happens here is that the esItem object is saved to the database. EntitySpaces seems to ignore the fact that there is a transaction scope. Is this a coding or configuration error? Should the Save function throw an exception itself because the wrong transaction scope type is used? If not, then merely setting the providerClass to "DataProviderEnterprise" and using esTransactionScope will have you thinking that you are saving data as part of a transaction when you actually aren't. I guess the same situation would apply if the providerClass was set to "DataProvider" and you used System.Transactions.TransactionScope. I apologize if this issue has been addressed in a later version.
I did some other tests and saw that the transaction was rolled back correctly if "DataProviderEnterprise" and TransactionScope are used together or "DataProvider" and esTransactionScope are used together.
Test 2: providerClass="DataProviderEnterprise" - save is rolled back
using (TransactionScope scope = new TransactionScope())
{
...
esItem.Save(); // EntitySpace object
// esItem save should be rolled back
throw new Exception("Test Transaction Exception");
}
Test 3: providerClass="DataProvider" - save is rolled back
using (esTransactionScope scope = new esTransactionScope())
{
...
esItem.Save(); // EntitySpace object
// esItem save should be rolled back
throw new Exception("Test Transaction Exception");
}
I think I have my answer based on the tests above but I'm not sure if Test 1 is a bug or whether it "works as designed". Perhaps an enhancement can be made to catch a mismatch of the providerClass and the transaction scope class.
Thanks for any advice or info you can give,
dadams