/// <summary> /// Visits a LinqToAstoriaExpandLambdaExpression. /// </summary> /// <param name="expression">The expression.</param> /// <returns>The result of visiting this expression.</returns> public CodeExpression Visit(LinqToAstoriaExpandLambdaExpression expression) { var source = this.GenerateQueryCode(expression.Source).Expression; var lambda = this.GenerateQueryCode(expression.Lambda).Expression as CodeLambdaExpression; Type clrType = this.GetClrType(expression.Source); return(source.Cast(Code.GenericType("DataServiceQuery", clrType.FullName)).Call("Expand", lambda)); }
/// <summary> /// Visits a LinqToAstoriaExpandLambdaExpression. /// </summary> /// <param name="expression">The expression.</param> /// <returns>The result of visiting this expression.</returns> public virtual QueryExpression Visit(LinqToAstoriaExpandLambdaExpression expression) { QueryExpression source = this.ReplaceExpression(expression.Source); if (HasChanged(expression.Source, source)) { return(new LinqToAstoriaExpandLambdaExpression(source, expression.Lambda, expression.ExpressionType)); } else { return(expression); } }
/// <summary> /// Visits a LinqToAstoriaExpandLambdaExpression. /// </summary> /// <param name="expression">The expression.</param> /// <returns>The result of visiting this expression.</returns> public Expression Visit(LinqToAstoriaExpandLambdaExpression expression) { Expression source = this.GenerateLinqExpression(expression.Source); Expression predicate = this.GenerateLinqExpression(expression.Lambda); Type sourceType = predicate.Type.GetGenericArguments()[0]; Type targetType = predicate.Type.GetGenericArguments()[1]; Type closedDataServiceQueryType = typeof(DataServiceQuery <>).MakeGenericType(new Type[] { sourceType }); Expression sourceAsDataServiceQuery = Expression.Convert(source, closedDataServiceQueryType); // public DataServiceQuery<TElement> Expand<TTarget>(Expression<Func<TElement, TTarget>> navigationPropertyAccessor) MethodInfo genericExpand = closedDataServiceQueryType.GetMethods().Single(m => m.IsPublic && m.Name == "Expand" && m.IsGenericMethod); MethodInfo closedGenericExpand = genericExpand.MakeGenericMethod(targetType); var result = Expression.Call(sourceAsDataServiceQuery, closedGenericExpand, predicate); return(result); }
/// <summary> /// Visits a LinqToAstoriaExpandLambdaExpression. /// </summary> /// <param name="expression">The expression.</param> /// <returns>The result of visiting this expression.</returns> public CodeExpression Visit(LinqToAstoriaExpandLambdaExpression expression) { CodeExpression source = this.GenerateQueryCode(expression.Source).Expression; var parameter = expression.Lambda.Parameters.Single(); var parameterDeclaration = new CodeParameterDeclarationExpression(new CodeImplicitTypeReference(), parameter.Name); this.ParameterNamesDictionary.Add(parameter, parameterDeclaration); CodeLambdaExpression lambda; try { lambda = (CodeLambdaExpression)this.GenerateCode(expression.Lambda); } finally { this.ParameterNamesDictionary.Remove(parameter); } Type clrType = this.GetClrType(expression.Source); return(source.Cast(Code.GenericType("DataServiceQuery", clrType.FullName)).Call("Expand", lambda)); }
/// <summary> /// Visits a LinqToAstoriaExpandLambdaExpression. /// </summary> /// <param name="expression">The expression.</param> /// <returns>The result of visiting this expression.</returns> public override string Visit(LinqToAstoriaExpandLambdaExpression expression) { return this.Visit(expression.ToLinqToAstoriaExpandExpression()); }
/// <summary> /// Visits a LinqToAstoriaExpandLambdaExpression. /// </summary> /// <param name="expression">The expression.</param> /// <returns>The result of visiting this expression.</returns> public virtual string Visit(LinqToAstoriaExpandLambdaExpression expression) { throw new TaupoNotSupportedException("Not supported"); }
/// <summary> /// Visits a LinqToAstoriaExpandLambdaExpression. /// </summary> /// <param name="expression">The expression.</param> /// <returns>The result of visiting this expression.</returns> public QueryExpression Visit(LinqToAstoriaExpandLambdaExpression expression) { var source = this.ResolveTypes(expression.Source); return(new LinqToAstoriaExpandLambdaExpression(expression.Source, expression.Lambda, source.ExpressionType)); }
/// <summary> /// Visits a LinqToAstoriaExpandLambdaExpression. /// </summary> /// <param name="expression">The expression.</param> /// <returns>The result of visiting this expression.</returns> public QueryValue Visit(LinqToAstoriaExpandLambdaExpression expression) { return(this.Evaluate(expression.ToLinqToAstoriaExpandExpression())); }
/// <summary> /// Visits a LinqToAstoriaExpandLambdaExpression. /// </summary> /// <param name="expression">The expression.</param> /// <returns>The result of visiting this expression.</returns> public override string Visit(LinqToAstoriaExpandLambdaExpression expression) { return(this.Visit(expression.ToLinqToAstoriaExpandExpression())); }