I have a function that is being called recursively. In this function, a TransactionScope
object with Isolation level ReadUncommitted
is being used. The strange behaviour is that the first time, it hits Database, locks the table and after the completion of first iteration, it releases the table and the behaviour is fine. Can anyone explain why? Please note that I'm using Core ADO.Net. No ORM. My functon looks like the following:
public void ExportTransactionsData()
{
var now = DateTime.Now;
var slash = ConfigurationReader.PathCharacterToUse;
var startId = 0L;
var endId = 0L;
var hasMoreRecords = false;
using (var transScope = UtilityMethods.TransactionScope(IsolationLevel.ReadUncommitted, TransactionScopeOption.Required))
{
using (var stream = _provider.GetTransactionsXml(out startId, out endId, out hasMoreRecords))
{
if (stream.Length > 0)
{
var filePath = $"{ConfigurationReader.TransactionFilePath}{slash}EZFareTransactions_{startId}_{endId}_{now.ToString("yyyyMMddTHHmmss")}.xml";
using (IUploadClient client = UploadClientFactory.Create(ConfigurationReader.UploadType))
{
client.Upload(filePath, stream);
}
}
}
transScope.Complete();
}
if (hasMoreRecords)
{
ExportTransactionsData();
}
}