Пример #1
0
        public override FunctionInformation OrderBy(MethodCallExpression methodExpression)
        {
            FunctionInformation information = new FunctionInformation
            {
                Name = "ORDER BY",
                MeaningfulArguments = new object[1],
                WhereContribution   = default(string),
                Type = FunctionInformation.FunctionType.Miscellaneous
            };

            Expression expression = ((LambdaExpression)((UnaryExpression)methodExpression.Arguments[1]).Operand).Body;

            if (expression.NodeType == ExpressionType.MemberAccess)
            {
                information.MeaningfulArguments[0] = ((MemberExpression)expression).Member.Name;
            }
            else if (expression.NodeType == ExpressionType.Parameter)
            {
                // Handling cases of OrderBy(a => a)
                string   fqn      = new FullyQualifiedNameVisitor().BringFQN(methodExpression);
                string[] splitFQN = fqn.Split('.');

                information.MeaningfulArguments[0] = splitFQN[splitFQN.Length - 1];
            }

            Logger.Log(
                "Function Information: " + information.ToLog(),
                Microsoft.Extensions.Logging.LogLevel.Debug
                );

            return(information);
        }
Пример #2
0
        /* ****************************************************************************************************** *
        * ---------------------------                HELPING METHODS              ------------------------------ *
        * ****************************************************************************************************** */

        private FunctionInformation BasicAggregateImplementation(MethodCallExpression methodExpression, string functionName, FunctionInformation.FunctionType functionType)
        {
            int argumentCount = methodExpression.Arguments.Count;

            FunctionInformation information = new FunctionInformation()
            {
                Name = functionName,
                Type = functionType,
                MeaningfulArguments = new object[1]
            };

            System.Type argumentType = methodExpression.Arguments[0].Type.GenericTypeArguments[0];

            string entityFullName = argumentType.IsInterface ? default(string) : argumentType.FullName;

            string fqn = new FullyQualifiedNameVisitor().BringFQN(methodExpression);

            fqn = fqn ?? entityFullName + (argumentCount > 1 ? GetSelectorBody(methodExpression.Arguments[1]) : "");

            information.MeaningfulArguments[0] = fqn;
            information.WhereContribution      = argumentCount > 1 ? OQLBuilder.BuildWhereClause(currentContext, methodExpression.Arguments[1], out OQLBuilder oqlBuilder).Trim() : default(string);

            Logger.Log(
                "Function Information: " + information.ToLog(),
                Microsoft.Extensions.Logging.LogLevel.Debug
                );

            return(information);
        }