public void DeleteHouse(int houseId) { if (!_databaseRepository.Any <House>(h => h.Id == houseId)) { throw new NotFoundException($"Дом с Id {houseId} не найден"); } var house = _databaseRepository.GetQueryable <House>(h => h.Meter).FirstOrDefault(h => h.Id == houseId); house.Meter = null; _databaseRepository.AddOrEdit(house); _databaseRepository.DeleteById <House>(houseId); }