public virtual bool CommitTransaction(ZOperationResult operationResult) { try { if (PersistenceHelper.IsTransaction) { if (Transaction != null) { if (Transaction.DataConnection != null && Transaction.DataConnection.Connection != null && Transaction.DataConnection.Connection.State == ConnectionState.Open) { Transaction.Commit(); } Transaction.Dispose(); Transaction = null; } } } catch (Exception exception) { operationResult.ParseExceptionLINQ2DB(exception); } return(operationResult.Ok); }
public LeaveCalculationsTests(ServicesFixture servicesFixture) { _sf = servicesFixture; _sf.DoOnce(f => f.SetupData()); _transaction = _sf.DbConnection.BeginTransaction(); _leaveService = _sf.Get <LeaveService>(); }
public MiscTests(ServicesFixture servicesFixture) { _servicesFixture = servicesFixture; _personRepository = _servicesFixture.Get <PersonRepository>(); _servicesFixture.DoOnce(fixture => fixture.SetupData()); _transaction = _servicesFixture.DbConnection.BeginTransaction(); }
public RoleTests(ServicesFixture servicesFixture) { _servicesFixture = servicesFixture; _db = _servicesFixture.DbConnection; _transaction = _db.BeginTransaction(); _personService = _servicesFixture.Get <PersonService>(); _personRepository = _servicesFixture.Get <PersonRepository>(); }
public LeaveRequestTests(ServicesFixture sf) { _sf = sf; _leaveService = _sf.Get <LeaveService>(); _orgGroupRepository = _sf.Get <OrgGroupRepository>(); _sf.DoOnce(fixture => fixture.SetupPeople()); _transaction = _sf.DbConnection.BeginTransaction(); _serviceScope = _sf.ServiceProvider.CreateScope(); _scopeServiceProvider = _serviceScope.ServiceProvider; }
public virtual void Dispose() { if (Transaction != null) { Transaction.Dispose(); Transaction = null; } Connection.Dispose(); }
protected virtual void Dispose(bool disposing) { if (!disposed) { if (disposing) { if (Transaction != null) { Transaction.Dispose(); Transaction = null; } } disposed = true; } }
// Critical section: // this method locks the schedule row for update, in order to coordinate job running. private static JobActivationStatus LockJobSchedule(JobSchedule jobSchedule, DataConnectionTransaction transaction) { Logger.Trace($"Locking {jobSchedule.Id}"); using (var reader = transaction.DataConnection.ExecuteReader( @"SELECT JobStatus FROM JobSchedule WITH(UPDLOCK, ROWLOCK) WHERE JobScheduleId = @jobScheduleId", new DataParameter("jobScheduleId", jobSchedule.Id))) { if (reader.Reader.Read()) { return(reader.Reader.GetInt32(0) > 1 ? JobActivationStatus.AlreadyRunning : JobActivationStatus.Idle); } else { return(JobActivationStatus.InvalidJob); } } }
public virtual bool BeginTransaction(ZOperationResult operationResult, bool isTransaction = true, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted) { try { if (isTransaction && PersistenceHelper.IsTransaction) { if (Transaction == null || Transaction.DataConnection == null) { Transaction = Connection.BeginTransaction(isolationLevel); } } } catch (Exception exception) { operationResult.ParseExceptionLINQ2DB(exception); } return(operationResult.Ok); }
public OrgGroupTests(ServicesFixture sf) { _sf = sf; _groupService = _sf.Get <OrgGroupService>(); _groupRepository = _sf.Get <OrgGroupRepository>(); _transaction = _sf.DbConnection.BeginTransaction(); var orgRootId = Guid.NewGuid(); org1Super = _sf.InsertPerson(); org1 = _sf.InsertOrgGroup(orgRootId, org1Super.Id, name: "org1", approvesLeave: true); org2Super = _sf.InsertPerson(); org2 = _sf.InsertOrgGroup(orgRootId, org2Super.Id, name: "org2", approvesLeave: true); org2a = _sf.InsertOrgGroup(org2.Id, name: "org2a"); org1aSuper = _sf.InsertPerson(); org1a = _sf.InsertOrgGroup(org1.Id, org1aSuper.Id, name: "org1a"); orgRoot = _sf.InsertOrgGroup(action: group => group.Id = orgRootId, name: "orgRoot"); org2aStaff = _sf.InsertStaff(org2a.Id); org1Staff = _sf.InsertStaff(org1.Id); org1aStaff = _sf.InsertStaff(org1a.Id); }
/// <summary> /// Initializes a new instance of <see cref="Linq2DbTransaction" />. /// </summary> /// <param name="dataConnectionTransaction">The data connection transaction that will be wrapped by this instance.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="dataConnectionTransaction"/> is null.</exception> public Linq2DbTransaction(DataConnectionTransaction dataConnectionTransaction) =>
internal TransactionScope(DataConnectionTransaction value) { _value = value; }
public void SetUp() { con = new Northwind(); tran = con.BeginTransaction(); }
public TrainingTests(ServicesFixture sf) { _sf = sf; _transaction = _sf.DbConnection.BeginTransaction(); _repo = _sf.Get <TrainingRepository>(); }
public JobTests(ServicesFixture servicesFixture) { _sf = servicesFixture; _js = _sf.Get <JobService>(); _transaction = _sf.DbConnection.BeginTransaction(); }