Exemplo n.º 1
0
        public static IList <DataProfileResult> GetSearchQuery(this IQueryable <DataProfileResult> query, string requestQuery, int page = Configurations.DefaultPageValue, int limit = Configurations.DefaultLimit, string order = Configurations.DefaultOrder)
        {
            var searchParams = QueryHelper.EnsureSearchQueryIsValid(requestQuery, QueryHelper.ParseSearchQuery);

            if (searchParams != null)
            {
                foreach (var searchParam in searchParams)
                {
                    if (ReflectionHelper.HasProperty(searchParam.Key, typeof(DataProfileResult)))
                    {
                        query = query.Where(String.Format("{0} = @0 || {0}.Contains(@0)", searchParam.Key), searchParam.Value);
                    }
                }
            }

            IList <DataProfileResult> result = new ApiList <DataProfileResult>(query, page - 1, limit);

            return(result.AsQueryable().OrderBy(order).ToList());
        }