public IEagerFetchingRepository <TEntity> EagerlyWith(Action <EagerFetchingStrategy <TEntity> > strategyActions) { try { return(_repository.EagerlyWith(strategyActions)); } catch (ApplicationException ex) { throw new RepositoryException("An error occured while eager loading an entity.", ex); } }
public override async Task <CommandResult <DiveLocation> > GetByIdAsync(object primaryKey) { var result = new CommandResult <DiveLocation>(); try { if (primaryKey == null) { result.ValidationResult.AddError(new ValidationError("Primary Key cannot be null", "primaryKey")); } if (result.ValidationResult.IsValid) { _diveLocationRepository.EagerlyWith(x => x.DiveLocationDetail); _diveLocationRepository.EagerlyWith(x => x.DiveType); Guid id = (Guid)primaryKey; result.DataResult = _diveLocationRepository.FirstOrDefault(x => x.Id == id); this.Logger.LogDebug("Getting entity of type {0} by Id: {1}.", typeof(DiveLocation), primaryKey); } else { this.Logger.LogWarning("Input was not validated for GetByIdAsync method - primaryKey of {0}", primaryKey); } } catch (ApplicationException ex) { result.Exception = ex; this.ExceptionManager.HandleException(ex, DefaultExceptionPolicies.BusinessWrapPolicy); } return(await Task.FromResult(result)); }