コード例 #1
0
        /// <summary>
        /// Performs one "insert into" database command.
        /// Will commit the transaction and close the connection (if configured to). Use for independent insert.
        /// </summary>
        /// <param name="EmployeesInfo">Object to insert.</param>
        /// <param name="errorMessage">Error message if exception is throwed</param>
        public virtual void InsertOne(EmployeesInfo parEmployeesInfo, out string errorMessage)
        {
            errorMessage = string.Empty;


            //1) Start the transaction context.
            DbTransaction transaction = motor.BeginTransaction();


            //2) Call the overload of this method, which call the DAO but does not commit.
            this.InsertOne(parEmployeesInfo, transaction, out errorMessage);

            //3) Commit the transaction.
            motor.Commit();

            //4) Close the conection (if configured to do so).
            if (this.closeConnectionWhenFinish)
            {
                motor.CloseConnection();
            }
        }