How do I extract a value from a Member Expression where the expression within the Member Expression is not a Constant, but a Parameter Expression.
I am building a small Linq to MDX ORM for our company.
In my generator template, each Dimension found in the database is a class, and in each dimension, there are the Attribute properties that are found for that dimension.  After all the dimension classes are generated, a higher level Cube class is generated that contains the Dimensions as properties, as well as the Measures for that cube.  After all the cube classes are generated, a final class is built that contains the cube classes that were generated as Cube<MyCube> properties, where the Cube<> is my IQueryable type. Here's an example.
//Generated cs file example:
public partial MyDatabase : CubeBase
{
    //Some base implementation goes here        
    public Cube<FooCube> FooCube { get { return new Cube<FirstCube>(new Provider("connection string"); } }
    //Any other cubes would follow here that were found on this database.
} 
//A calendar dimension
public class FooCube_CalendarDimension
{
    public Attribute WeekEnding { get { return new Attribute("[Calendar].[Week Ending]"); } }
    public Attribute Month { get { return new Attribute("[Calendar].[Month]"); } }
    public Attribute Year { get { return new Attribute("[Calendar].[Year]"); } }
}
//The "FooCube" 
public partial class FooCube
{
    //List Dimensions
    public FooCube_Calendar_Dimension Calendar { get { return new FooCube_Calendar_Dimension(); }     }
    //Other dimensions here
    [Measure]
    public string RetailDollars { get { return "[Retail Dollars]"; } }
    // Other measures here
}
Now, an example of a very basic linq query to query the cube:
//using MyDatabase = db
var mdx = from cube in db.FooCube
          where cube.Calendar.Year == "2014"
          select new
          {
              Month = cube.Calendar.Month.Children
              Dollars = cube.RetailDollars
          }
For example, I'm trying to get the value from cube.Calendar.Month.Children, which comes from the Attribute object that is a property of the FooCube_Calendar_Demsion class, that is in itself a property in the "FooCube" class.
I tried the answer from Access the value of a member expression, but I get the error, "the 'cube' parameter was not referenced" when it tries to compile the lambda expression. The value that it passes to the attribute class's constructor is stored in a property, and that's the value (one of them) that I want to access.
 
     
    