public virtual SearchForResponse <TDto> SearchFor(SearchForRequest <TDto> request)
        {
            var response = new SearchForResponse <TDto> {
                IsSuccess = false, ItemList = null
            };

            try
            {
                var results = new List <TDto>();
                var models  = _repository.SearchFor(new SearchForRequest <TEntity>(request.Predicate, request.RequestBase)).ToList();
                if (models.Any())
                {
                    results.AddRange(models.Select(model => MapToDto(model)));
                    response.ItemList = results;
                }

                response.ErrorMessage = "Search yielded no results.";
                response.ItemList     = new List <TDto>();
                return(response);
            }
            catch (DbEntityValidationException dbx)
            {
                // Retrieve the error messages as a list of strings.
                var errorMessages = dbx.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join("; ", errorMessages);

                // Combine the original exception message with the new one.
                var exceptionMessage = string.Concat(dbx.Message, " The validation errors are: ", fullErrorMessage);

                // Throw a new DbEntityValidationException with the improved exception message.
                throw new System.Exception(exceptionMessage);
            }
            catch (System.Exception ex)
            {
                ErrorHandler.LogException(ex);
                response.ErrorMessage = ErrorsEnum.ExceptionEncountered.FriendlyErrorMessage();
                response.IsSuccess    = false;
                response.ErrorCode    = (int)ErrorsEnum.ExceptionEncountered;
                response.ItemList     = null;
                return(response);
            }
        }
        public IQueryable <TEntity> SearchFor(SearchForRequest <TEntity> request)
        {
            var expression = request.Predicate.ToBooleanExpression <TEntity>();

            return(DbSet.Where(expression));
        }
 public SearchForResponse <ProductDto> SearchFor(SearchForRequest <ProductDto> request)
 {
     return(BranchLogic.SearchFor(request));
 }