private MethodInfo GetExpandMethodInfo <TElement, TTarget>(Expression <Func <TElement, TTarget> > navigationPropertyAccessor) { var dsq = (DataServiceQuery <TElement>)DbFixtureInitDb.GetQuerableOe(_container, navigationPropertyAccessor.Parameters[0].Type); Func <Expression <Func <TElement, TTarget> >, DataServiceQuery <TElement> > expand = dsq.Expand; return(expand.GetMethodInfo()); }
protected override Expression VisitMember(MemberExpression node) { if (node.Expression is ConstantExpression && node.Type.IsGenericType && node.Type.GetGenericTypeDefinition() == typeof(IQueryable <>)) { Type entityType = node.Type.GetGenericArguments()[0]; IQueryable source = DbFixtureInitDb.GetQuerableOe(_container, entityType); return(source.Expression); } return(Expression.MakeMemberAccess(base.Visit(node.Expression), Map(node.Member))); }
protected override Expression VisitParameter(ParameterExpression node) { if (typeof(IQueryable).IsAssignableFrom(node.Type)) { Type entityType = node.Type.GetGenericArguments()[0]; IQueryable source = DbFixtureInitDb.GetQuerableOe(_container, entityType); return(source.Expression); } if (_parameters.TryGetValue(node, out ParameterExpression parameter)) { return(parameter); } parameter = Expression.Parameter(Map(node.Type), node.Name); _parameters.Add(node, parameter); return(parameter); }