/* ****************************************************************************************************** * * --------------------------- 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); }
internal static string BuildWhereClause(DbContext context, Expression node, out OQLBuilder builder) { builder = new OQLBuilder(context); builder.Visit(node); return(builder.whereBuilder.ToString()); }
internal static string ExpressionToOQL(DbContext context, Expression node, out OQLBuilder oqlBuilder) { Debug.Assert(node != null); ValidationResult result = new OQLQueryAnalyzer(node).ValidateQuery(); if (!result.IsValid) { throw new Exception(result.Reason); } oqlBuilder = new OQLBuilder(context); oqlBuilder.Visit(node); return(oqlBuilder.BuildQuery()); }