public override Expression Output(OneToManyQueryDetailWalkInfo walkInfo) { var expression = BuildWhereExpression(walkInfo); expression = BuildOrderExpression(expression, walkInfo); expression = BuildSelectExpression(expression, walkInfo); var toListMethod = MethodProvider.MakeGenericMethod(typeof(Enumerable), "ToList", new Type[] { typeof(IEnumerable <>) }, new Type[] { walkInfo.Type }); return(Expression.Call(toListMethod, expression)); }
private Expression BuildSelectExpression(Expression expression, OneToManyQueryDetailWalkInfo walkInfo) { var memberInitializationExpression = Expression.Lambda( typeof(Func <,>).MakeGenericType(walkInfo.Type, walkInfo.Type), BuildMemberInitExpression(), walkInfo.Member as ParameterExpression); var selectMethod = MethodProvider.MakeGenericMethod(typeof(Enumerable), "Select", new Type[] { typeof(IEnumerable <>), typeof(Func <,>) }, new Type[] { walkInfo.Type, walkInfo.Type }); return(Expression.Call( selectMethod, expression ?? walkInfo.DetailMember, memberInitializationExpression)); }
private Expression BuildWhereExpression(OneToManyQueryDetailWalkInfo walkInfo) { var filterExpression = BuildFilterExpression(walkInfo); if (filterExpression != null) { var whereMethod = MethodProvider.MakeGenericMethod(typeof(Enumerable), "Where", new Type[] { typeof(IEnumerable <>), typeof(Func <,>) }, new Type[] { walkInfo.Type }); return(Expression.Call( whereMethod, walkInfo.DetailMember, filterExpression)); } return(null); }