/// <summary>
        /// Handles the LLBLGenProDataSource PerformWork Event which is raised when LivePersistence is set to false and an insert/update/delete has to be performed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void EmployeeDetailsDS_PerformWork(object sender, PerformWorkEventArgs2 e)
        {
            #region Get the entityToDelete from UOW
            EmployeeEntity entityToDelete = null;
            // If found, get the entity to be deleted from the UnitOfWork object.
            List <UnitOfWorkElement2> deleteItems = e.Uow.GetEntityElementsToDelete();
            if (deleteItems.Count > 0)
            {
                entityToDelete = (EmployeeEntity)deleteItems[0].Entity;
            }
            #endregion

            #region Get the entityToUpdate from UOW
            EmployeeEntity entityToUpdate = null;
            // If found, get the entity to be updated from the UnitOfWork object.
            List <UnitOfWorkElement2> updateItems = e.Uow.GetEntityElementsToUpdate();
            if (updateItems.Count > 0)
            {
                entityToUpdate = (EmployeeEntity)updateItems[0].Entity;
                //Set the Photo of the EMployee, if uploaded.
                SetPicture(entityToUpdate);
            }
            #endregion

            #region Get the entityToInsert from UOW
            EmployeeEntity entityToInsert = null;
            // If found, get the entity to be inserted from the UnitOfWork object.
            List <UnitOfWorkElement2> inserteItems = e.Uow.GetEntityElementsToInsert();
            if (inserteItems.Count > 0)
            {
                entityToInsert = (EmployeeEntity)inserteItems[0].Entity;
                //Set the Photo of the EMployee, if uploaded.
                SetPicture(entityToInsert);
            }
            #endregion

            #region Determining the entity to validate

            // entity to be validated
            EmployeeEntity entityToValidate = null;

            // flag to know whether the entity is valid
            bool entityToValidateIsValid = true;


            if (entityToInsert != null)
            {
                entityToValidate = entityToInsert;
            }

            if (entityToUpdate != null)
            {
                entityToValidate = entityToUpdate;
            }
            #endregion


            #region Validating the entity via ValidateEntity() method
            if (entityToValidate != null)
            {
                try
                {
                    // perform the validate process
                    entityToValidate.ValidateEntity();

                    // everything OK, lets hide the error controls
                    HideEntityErrorControls();
                }
                catch (ORMEntityValidationException ex)
                {
                    // oops, there are errors somewhere, lets show to the user
                    ShowEntityErrors(ex.Message);
                    entityToValidateIsValid = false;
                }
            }
            #endregion


            #region Perform the work
            if (entityToValidateIsValid)
            {
                try
                {
                    DataAccessAdapter adapter = new DataAccessAdapter();
                    e.Uow.Commit(adapter, true);
                }
                catch (ORMQueryExecutionException ex)
                {
                    /// catch other errors
                    /// ...
                }
            }
            #endregion
        }