I have a very important question which I need help with. I will try to strip the problem down to this example:
Having a wcf/web service implementation (but it could be any other module) as follows:
public class Svc: ISvc
{
public void PerformSimpleOperations()
{
try
{
// insert in other tables here (calling stored procs)
/* important line here */
dbHandler.InsertRecordInSpecificTable(recordType1);
// commit transaction (default isolation level)
dbHandler.CommitTransactDB();
}
catch
{
dbHandler.RollbackTransactDB();
}
}
public void PerformComplexOperations()
{
try
{
// some complex operations here involving db (calling stored procs)
/* important lines here */
dbHandler.InsertRecordInSpecificTable(recordBEGIN);
foreach (var recordType2 in arrayOfRecordsType2)
dbHandler.InsertRecordInSpecificTable(recordType2);
dbHandler.InsertRecordInSpecificTable(recordEND);
// commit transaction (default isolation level)
dbHandler.CommitTransactDB();
}
catch
{
dbHandler.RollbackTransactDB();
}
}
}
There are 2 different methods which insert records, transaction based (ADO.NET SQLTransaction with default isolation level), into one 'SpecificTable' in database (of course called at anytime by different threads).
As it can be seen in the example, first method just inserts simple records of 'type1', but the second method inserts a bulk of records of 'type2' starting with some 'BEGIN' & 'END' identifiers so that this bunch could be processed as a whole later on by another application.
Since all the records have auto-incremental ID, my intent is to have in this table in between 'BEGIN' & 'END' only records of 'type2'.
Question is: Would it be possible that in this table, in between 'BEGIN' & 'END' records, to have slipped records of 'type1'?
AFAIK the database should be locked during that transaction (default isolation level) and normally this behavior should not happen, so my implementation should be right. Is it correct or I miss something important here?
Thanks a lot!