public bool Equals(ConfiguredLaptopModel otherConfiguredLaptopModel) { if (otherConfiguredLaptopModel is null) { return(false); } if (ReferenceEquals(this, otherConfiguredLaptopModel)) { return(true); } foreach (var ConfigurationItem in ConfigurationItems) { var item = otherConfiguredLaptopModel.ConfigurationItems.FirstOrDefault(w => w.Id == ConfigurationItem.Id && w.Equals(ConfigurationItem)); if (item == null) { return(false); } if (item.Equals(ConfigurationItem)) { if (Laptop.Equals(otherConfiguredLaptopModel.Laptop)) { return(true); } } } return(Laptop.Equals(otherConfiguredLaptopModel.Laptop) && ConfigurationItems.Equals(otherConfiguredLaptopModel.ConfigurationItems)); }