Example #1
0
 private FilterLambdaOperatorDescriptor GetFilterExpressionDescriptor <T>(OperatorDescriptorBase filterBody, string parameterName = "$it")
 => new FilterLambdaOperatorDescriptor
 {
     FilterBody        = filterBody,
     SourceElementType = typeof(T).AssemblyQualifiedName,
     ParameterName     = parameterName
 };
        private static OperatorDescriptorBase GetTakeOperator(this OperatorDescriptorBase pagingDescriptor, SortCollectionDescriptor sortCollectionDescriptor)
        => sortCollectionDescriptor.Take.HasValue
                ? new TakeOperatorDescriptor
        {
            SourceOperand = pagingDescriptor,
            Count         = sortCollectionDescriptor.Take.Value
        }

                : pagingDescriptor;
Example #3
0
 private SelectorLambdaOperatorDescriptor GetExpressionDescriptor <T, TResult>(OperatorDescriptorBase selectorBody, string parameterName = "$it")
 => new SelectorLambdaOperatorDescriptor
 {
     Selector          = selectorBody,
     SourceElementType = typeof(T).AssemblyQualifiedName,
     ParameterName     = parameterName,
     BodyType          = typeof(TResult).AssemblyQualifiedName
 };
Example #4
0
 public static IExpressionPart MapToOperator(this IMapper mapper, OperatorDescriptorBase expression)
 => mapper.Map <IExpressionPart>
 (
     expression,
     opts => opts.Items[PARAMETERS_KEY] = GetParameters()
 );
        private static OperatorDescriptorBase CreateSortBody(SortCollectionDescriptor sortCollectionDescriptor, OperatorDescriptorBase sourceOperand)
        {
            if (sortCollectionDescriptor?.SortDescriptions?.Any() != true)
            {
                throw new ArgumentException($"{nameof(sortCollectionDescriptor.SortDescriptions)}: C55F5642-5811-4840-B643-E38BDE7DA16E");
            }

            return(sortCollectionDescriptor.SortDescriptions.Aggregate
                   (
                       sourceOperand,
                       (OperatorDescriptorBase descriptor, SortDescriptionDescriptor next) =>
            {
                return object.ReferenceEquals(descriptor, sourceOperand)
                        ? new OrderByOperatorDescriptor
                {
                    SortDirection = next.SortDirection,
                    SourceOperand = descriptor,
                    SelectorBody = new MemberSelectorOperatorDescriptor
                    {
                        SourceOperand = new ParameterOperatorDescriptor {
                            ParameterName = selectorParameterName
                        },
                        MemberFullName = next.PropertyName
                    },
                    SelectorParameterName = selectorParameterName
                }
                        : new ThenByOperatorDescriptor
                {
                    SortDirection = next.SortDirection,
                    SourceOperand = descriptor,
                    SelectorBody = new MemberSelectorOperatorDescriptor
                    {
                        SourceOperand = new ParameterOperatorDescriptor {
                            ParameterName = selectorParameterName
                        },
                        MemberFullName = next.PropertyName
                    },
                    SelectorParameterName = selectorParameterName
                };
            }
                   ));
        }
 private static SelectorLambdaOperatorDescriptor GetSelector(string queryableType, SortCollectionDescriptor sortDescriptor, OperatorDescriptorBase sourceOperand)
 => new SelectorLambdaOperatorDescriptor
 {
     Selector = CreatePagingDescriptor
                (
         sortDescriptor,
         CreateSortBody
         (
             sortDescriptor,
             sourceOperand
         )
                ),
     ParameterName     = queryParameterName,
     BodyType          = queryableType,
     SourceElementType = queryableType
 };
 private static OperatorDescriptorBase CreatePagingDescriptor(SortCollectionDescriptor sortCollectionDescriptor, OperatorDescriptorBase sortBody)
 => sortBody.GetSkipOperator(sortCollectionDescriptor).GetTakeOperator(sortCollectionDescriptor);