private IQueryable <T> ApplyWhere(IQueryable <T> queryable)
        {
            var predicates = new List <string>();
            var values     = new List <object>();

            var counter = new PlaceHolderCounter();

            foreach (var queryArgumentInfo in _list.FilterBy(QueryArgumentInfoType.GraphQL))
            {
                foreach (var argument in _arguments)
                {
                    if (string.Equals(argument.Key, queryArgumentInfo.QueryArgument?.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        var predicate = BuildPredicate(queryArgumentInfo, argument.Value, counter);
                        if (predicate != null)
                        {
                            predicates.Add(predicate.Value.Text);
                            values.AddRange(predicate.Value.Values);
                        }
                    }
                }
            }

            return(predicates.Any() ? queryable.Where(string.Join($" {Operators.And} ", predicates), values.ToArray()) : queryable);
        }
Esempio n. 2
0
        private IQueryable <T> ApplyWhere(IQueryable <T> queryable)
        {
            var predicates = new List <string>();

            foreach (var queryArgumentInfo in _list.FilterBy(QueryArgumentInfoType.GraphQL))
            {
                foreach (var argument in _arguments)
                {
                    if (string.Equals(argument.Key, queryArgumentInfo.QueryArgument?.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        var predicate = BuildPredicate(queryArgumentInfo, argument.Value);
                        if (predicate != null)
                        {
                            predicates.Add(predicate);
                        }
                    }
                }
            }

            return(predicates.Any() ? queryable.Where(string.Join($" {Operators.And} ", predicates)) : queryable);
        }