- Home
- LLBLGen Pro
- LLBLGen Pro Runtime Framework
Transaction not wroking
Joined: 28-Oct-2009
Hi,
I had posted the issue in Architecture group and have not received any exact help.
Can somebody help me and let me know why transaction code is behaving wierd and not serving the porpose it is written for.
We are using selfservicing . SQL Server 2005 database.
the code written is very simple.
we generated the code using the SQL Server datbase . and we were trying to implement Transaction Feature using LLBLGen on the entities generated from database.
This is the first time we are trying the transaction piece as part of POC .
The Problem :
Transaction transactionManager = new Transaction(); Entity entity = new Entity(23);// 23 id i database entity.filedname = "xyz" // field to be updated transactionManager .Add(entity); entity.save(); //this saves everything and transaction.commit or rollback have no relevence.
transactionManager .Commit(); transactionManager .RollBack();
the above commit() and Rolback() methods are not wrking on the entity which is added to transaction.
behavior:
- Even if i comment the commit or rollback. the save happens.
When we add something to a transaction, we expect the commit() to be called for things in the transaction to be committed. the rollback should revert back the changes.
This is not happening. we are doing POC with LLBLgen and need to convinse our managers.
please help us out to understand the transaction part of LLBLgen . i did read the documents. but document says as i have written.
The exact code written is :
Database : SQL Server, But we tested on Oracle also and behavior is same. so i think its not Datbase issue.
The code giving issue :
public void UpdateCliamantTypeListInfo(UiClaimmstrVlntryAddrDTO dto) {
string name = Guid.NewGuid().ToString();
Transaction transactionManager = new Transaction(IsolationLevel.ReadCommitted, name);
try
{
TClamMstrDTO clmMstDTO = new TClamMstrDTO();
clmMstDTO.IsNew = dto.IsNew;
//clmMstDTO.Clmid = dto.Clmid_;
clmMstDTO.ClmType = dto.ClmType;
clmMstDTO.ClmStus = dto.ClmStus;
clmMstDTO.CrtdBy = " XXX ";
clmMstDTO.CrtdDt = DateTime.Now;
clmMstDTO.UpdtdBy = " XXX ";
clmMstDTO.UpdtdDt = DateTime.Now;
TClamMstrEntity clmMstrEnt = new TClamMstrEntity(clmMstDTO);
transactionManager.Add(clmMstrEnt);
clmMstrEnt.Save();
TClamAddrDTO clmAddrDTO = new TClamAddrDTO();
clmAddrDTO.IsNew = dto.IsNew;
clmAddrDTO.Clmid = clmMstrEnt.Clmid;
clmAddrDTO.AddrLine1 = dto.AddrLine1;
clmAddrDTO.AddrLine2 = dto.AddrLine2;
clmAddrDTO.AddrType = dto.AddrType;
clmAddrDTO.City = dto.City;
clmAddrDTO.State = dto.State;
clmAddrDTO.Zip = dto.Zip;
clmAddrDTO.CrtdDt = DateTime.Now;
clmAddrDTO.CrtdBy = "XXX";
clmAddrDTO.UpdtdDt = DateTime.Now;
clmAddrDTO.UpdtdBy = "XXX";
TClamAddrEntity clmAddrEnt = new TClamAddrEntity(clmAddrDTO);
transactionManager.Add(clmAddrEnt);
clmAddrEnt.Save();
TVlntryClmDTO objVlnDTO = new TVlntryClmDTO();
objVlnDTO.IsNew = dto.IsNew;
objVlnDTO.Clmid = clmMstrEnt.Clmid;
objVlnDTO.ClmntFname = dto.ClmntFname;
objVlnDTO.ClmntLname = dto.ClmntLname;
objVlnDTO.ClmntSsn = dto.ClmntSsn;
objVlnDTO.CrtdBy = " XXX ";
objVlnDTO.CrtdDt = DateTime.Now;
objVlnDTO.UpdtdBy = " XXX ";
objVlnDTO.UpdtdDt = DateTime.Now;
TVlntryClmEntity vlnEnt = new TVlntryClmEntity(objVlnDTO);
transactionManager.Add(vlnEnt);
vlnEnt.Save();
//transactionManager.Commit();
//transactionManager.Rollback();
}
catch (Exception ex)
{
transactionManager.Rollback();
ExceptionManager.HandleException(ex);
}
finally
{
transactionManager.Dispose();
}
}
Note :
We commented the commit transaction, but still the Save above for the entities is working. Are we doing anything wrong
We tried Rollback , but still nothing is rolling back.
If code written is correct. Could it be because of the transaction code generated otr any other reason.
please suggest.