protected bool Equals(Employee other)
        {
            var isEqual = this.UserId == other.UserId && this.EmployeeId.Equals(other.EmployeeId) && this.KeyPass.Equals(other.KeyPass)
                          && string.Equals(this.LastName, other.LastName) && string.Equals(this.FirstName, other.FirstName)
                          && this.BirthDate.Equals(other.BirthDate) && this.WorkstationId == other.WorkstationId
                          && string.Equals(this.FullName, other.FullName);

            if (isEqual)
            {
                if (!_isCheckingForWorkstationEquality)
                {
                    _isCheckingForWorkstationEquality = true;
                    try
                    {
                        return object.Equals(this.Workstation, other.Workstation);
                    }
                    finally
                    {
                        _isCheckingForWorkstationEquality = false;
                    }
                }
            }

            return isEqual;
        }
 protected bool Equals(Employee other)
 {
     return this.UserId == other.UserId && this.EmployeeId.Equals(other.EmployeeId) && this.KeyPass.Equals(other.KeyPass)
            && string.Equals(this.LastName, other.LastName) && string.Equals(this.FirstName, other.FirstName)
            && this.BirthDate.Equals(other.BirthDate) && this.WorkstationId == other.WorkstationId
            && string.Equals(this.FullName,other.FullName);
 }
 public void WhenIUpdateAllTheInsertedEmployeeEntities(bool useAsyncMethods)
 {
     foreach (var insertedEntity in _testContext.InsertedEntities.OfType<Employee>())
     {
         var updatedEntity = new Employee()
         {
             // all the properties linked to the composite primary key must be used
             UserId = insertedEntity.UserId,
             EmployeeId = insertedEntity.EmployeeId,
             BirthDate = new DateTime(2020, 03, 01),
             WorkstationId = 10 + insertedEntity.WorkstationId,
             FirstName = "Updated " + insertedEntity.FirstName,
             LastName = "Updated " + insertedEntity.LastName
         };
         _testContext.UpdatedEntities.Add(updatedEntity);
         if (useAsyncMethods)
         {
             _testContext.DatabaseConnection.UpdateAsync(updatedEntity).GetAwaiter().GetResult();
         }
         else
         {
             _testContext.DatabaseConnection.Update(updatedEntity);
         }
     }
 }
        public void WhenIPartiallyUpdateAllTheInsertedEmployeeEntities()
        {
            // prepare a new mapping
            var defaultMapping = OrmConfiguration.GetDefaultEntityMapping<Employee>();
            Assert.IsTrue(defaultMapping.IsFrozen);

            var lastNamePropMapping = defaultMapping.GetProperty(employee => employee.LastName);
            try
            {
                // updates are not possible when the mapping is frozen
                defaultMapping.SetProperty(nameof(Employee.LastName), PropertyMappingOptions.ExcludedFromUpdates);
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
            }

            var customMapping = defaultMapping.Clone().UpdatePropertiesExcluding(prop => prop.IsExcludedFromUpdates = true, nameof(Employee.LastName));

            foreach (var insertedEntity in _testContext.InsertedEntities.OfType<Employee>())
            {
                var partialUpdatedEntity = new Employee()
                {
                    UserId = insertedEntity.UserId,
                    EmployeeId = insertedEntity.EmployeeId,
                    BirthDate = new DateTime(2020, 03, 01),
                    WorkstationId = 10 + insertedEntity.WorkstationId,
                    FirstName = "Updated " + insertedEntity.FirstName,

                    // all of the above should be excluded with the exception of this one
                    LastName = "Updated " + insertedEntity.LastName
                };
                _testContext.UpdatedEntities.Add(new Employee()
                {
                    UserId = insertedEntity.UserId,
                    KeyPass = insertedEntity.KeyPass,
                    EmployeeId = insertedEntity.EmployeeId,
                    BirthDate = insertedEntity.BirthDate,
                    WorkstationId = insertedEntity.WorkstationId,
                    FirstName = insertedEntity.FirstName,

                    // all of the above should be excluded with the difference of this one
                    LastName = "Updated " + insertedEntity.LastName
                });
                _testContext.DatabaseConnection.Update(partialUpdatedEntity, entityMappingOverride: customMapping);
            }

        }
 public void WhenIQueryForTheInsertedEmployeeEntities(bool useAsyncMethods)
 {
     foreach (var insertedEntity in _testContext.InsertedEntities.OfType<Employee>())
     {
         var entityQuery = new Employee() { UserId = insertedEntity.UserId, EmployeeId = insertedEntity.EmployeeId };
         _testContext.QueriedEntities.Add(useAsyncMethods
             ?_testContext.DatabaseConnection.GetAsync<Employee>(entityQuery).Result
             :_testContext.DatabaseConnection.Get<Employee>(entityQuery));
     }
 }