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); }
/* ****************************************************************************************************** * * --------------------------- 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); }
public override FunctionInformation Select(MethodCallExpression methodExpression) { FunctionInformation information = new FunctionInformation(); Logger.Log( "Function Information (Select): " + information.ToLog(), Microsoft.Extensions.Logging.LogLevel.Debug ); return(information); }
public override FunctionInformation OrderByDescending(MethodCallExpression methodExpression) { FunctionInformation information = OrderBy(methodExpression); Logger.Log( "Function Information (Descending): " + information.ToLog(), Microsoft.Extensions.Logging.LogLevel.Debug ); return(information); }
public override FunctionInformation Count(MethodCallExpression methodExpression) { FunctionInformation information = BasicAggregateImplementation(methodExpression, "COUNT", FunctionInformation.FunctionType.Aggregate); // Remove attribute from the COUNT's argument as OQL works on the supposition that the COUNT's argument // is an entity and it is indexed. information.MeaningfulArguments[0] = RemoveAttributeAndCheckExistence(information.MeaningfulArguments[0].ToString()); Logger.Log( "Function Information: " + information.ToLog(), Microsoft.Extensions.Logging.LogLevel.Debug ); return(information); }