public Companies SelectCompanyById(int customerId) { try { Companies responseEntitiy; using (var repo = new CompaniesRepository()) { responseEntitiy = repo.SelectedById(customerId); responseEntitiy.Vehicles = new VehiclesRepository().SelectAll().Where(x => x.CompanyID.Equals(responseEntitiy.CompanyID)).ToList(); if (responseEntitiy == null) { throw new NullReferenceException("Customer doesnt exists!"); } } return(responseEntitiy); } catch (Exception ex) { LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true); throw new Exception("BusinessLogic:CompaniesBusiness::SelectCompanyById::Error occured.", ex); } }