public Expression <Func <ElmahErrorDto, bool> > CreateCustomDtoPredicate(object searchModel)
        {
            Expression <Func <ElmahErrorDto, bool> > predicate = f => true;
            ElmahErrorSearchViewModel model = (ElmahErrorSearchViewModel)(object)searchModel;

            predicate = e => (model.Host == null ? true : e.Host == model.Host) &&
                        (model.Type == null ? true : e.Type.StartsWith(model.Type)) &&
                        (string.IsNullOrWhiteSpace(model.ErrorIdString) ? true : e.Errorid.ToString().ToUpper().StartsWith(model.ErrorIdString.ToUpper().Trim())) &&
                        (model.User == null ? true : e.User.Contains(model.User)) &&
                        (model.Message == null ? true : e.Message.Contains(model.Message)) &&
                        (model.Source == null ? true : e.Source.StartsWith(model.Source)) &&
                        ((model.Application == null || model.Application.Count == 0) ? true : model.Application.Contains(e.Application)) &&
                        (model.Sequence == 0 ? true : e.Sequence == model.Sequence) &&
                        (model.IsAutoRefresh ? true : e.Kayityaratmatarihi >= model.StartDate) &&
                        (model.IsAutoRefresh ? true : e.Kayityaratmatarihi <= model.EndDate) &&
                        (string.IsNullOrWhiteSpace(model.MessageNotLike) ? true : !e.Message.Contains(model.MessageNotLike))
            ;
            return(predicate);
        }
        public override IEnumerable <TEntityDto> WhereDto <TSearchModel, TEntityDto>(TSearchModel searchModel, int pageIndex = 0, int pageSize = 0)
        {
            IEnumerable <ElmahErrorDto> elmahDataDto;
            ElmahErrorSearchViewModel   elmahSearchModel = (ElmahErrorSearchViewModel)(object)searchModel;

            if (elmahSearchModel.StartDate >= DateTime.Today.AddDays(-7))
            {
                Expression <Func <ElmahErrorDto, bool> > predicate = f => true;
                predicate = CreateCustomDtoPredicate(searchModel);

                var elmahData = UpdateCache().Where(predicate);
                elmahDataDto = (from e in elmahData
                                orderby e.Kayityaratmatarihi descending
                                select e).Take(1000);
            }
            else
            {
                IQueryable <ElmahError> elmahData = rep.Table;

                elmahData    = CustomFilter(elmahData, elmahSearchModel);
                elmahDataDto = (from e in elmahData
                                orderby e.Kayityaratmatarihi descending
                                select new ElmahErrorDto
                {
                    Errorid = e.Errorid,
                    Application = e.Application,
                    Host = e.Host,
                    Type = e.Type,
                    Source = e.Source,
                    Message = e.Message,
                    User = e.User,
                    Sequence = e.Sequence,
                    Kayityaratmatarihi = e.Kayityaratmatarihi
                }).Take(1000);
            }
            return((IEnumerable <TEntityDto>)elmahDataDto.AsEnumerable());
        }
 public IQueryable <ElmahError> CustomFilter(IQueryable <ElmahError> elmahData, ElmahErrorSearchViewModel elmahSearchModel)
 {
     if (elmahSearchModel.Host != null)
     {
         elmahData = (from e in elmahData
                      where e.Host == elmahSearchModel.Host
                      select e);
     }
     if (elmahSearchModel.Type != null)
     {
         elmahData = (from e in elmahData
                      where e.Type.StartsWith(elmahSearchModel.Type)
                      select e);
     }
     if (elmahSearchModel.Message != null)
     {
         elmahData = (from e in elmahData
                      where e.Message.Contains(elmahSearchModel.Message)
                      select e);
     }
     if (!string.IsNullOrWhiteSpace(elmahSearchModel.ErrorIdString))
     {
         elmahData = (from e in elmahData
                      where e.Errorid.ToString().ToUpper().StartsWith(elmahSearchModel.ErrorIdString.ToUpper().Trim())
                      select e);
     }
     if (!string.IsNullOrWhiteSpace(elmahSearchModel.MessageNotLike))
     {
         elmahData = (from e in elmahData
                      where !e.Message.Contains(elmahSearchModel.Message.Trim())
                      select e);
     }
     if (elmahSearchModel.User != null)
     {
         elmahData = (from e in elmahData
                      where e.User.Contains(elmahSearchModel.User)
                      select e);
     }
     if (elmahSearchModel.Source != null)
     {
         elmahData = (from e in elmahData
                      where e.Source.StartsWith(elmahSearchModel.Source)
                      select e);
     }
     if (elmahSearchModel.Application != null && elmahSearchModel.Application.Count != 0)
     {
         elmahData = (from e in elmahData
                      where elmahSearchModel.Application.Contains(e.Application)
                      select e);
     }
     if (elmahSearchModel.Sequence != 0)
     {
         elmahData = (from e in elmahData
                      where e.Sequence == elmahSearchModel.Sequence
                      select e);
     }
     if (elmahSearchModel.IsAutoRefresh == false)
     {
         elmahData = (from e in elmahData
                      where
                      e.Kayityaratmatarihi >= elmahSearchModel.StartDate &&
                      e.Kayityaratmatarihi <= elmahSearchModel.EndDate
                      select e);
     }
     return(elmahData);
 }