Example #1
0
 /// <summary>Constructor.</summary>
 /// <param name="dataService">      The data service. </param>
 /// <param name="parentUnitOfWork"> The parent unit of work. </param>
 public DapperUnitOfWork(DapperDataService dataService, DapperUnitOfWork parentUnitOfWork) : base(dataService)
 {
     _ownsConnection   = false;
     DapperDataService = dataService;
     Connection        = parentUnitOfWork.Connection;
     Transaction       = parentUnitOfWork.Transaction;
 }
Example #2
0
        /// <summary>	Constructor. </summary>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when one or more required arguments are
        ///     null.
        /// </exception>
        /// <param name="dataService">      The data service. </param>
        public DapperUnitOfWork(DapperDataService dataService) : base(dataService)
        {
            DapperDataService = dataService ?? throw new ArgumentNullException(nameof(dataService));

            // create and open connection
            Connection = DapperDataService.ConnectionFactory.CreateConnection(DapperDataService.ConnectionString);
            Connection.Open();

            // begin transaction
            Transaction = Connection.BeginTransaction();
        }