I need to write a LambdaExpression which is given below:
(a) => a.o.MovieType
where the definition of a is:
public class A<T, U> : EntityObject
where T : EntityObject
where U : EntityObject
{
public T o { get; private set; }
public U p { get; private set; }
public static Expression<Func<T, U, A<T, U>>> TempProjectedExpression
{
get
{
return (o, p) => new A<T, U>
{
o = o,
p = p
};
}
}
}
I wrote the following lambdaExpression to achieve my goal i.e. (a) => a.o.MovieType
me = Expression.Property(pe1, _ResultantType.GetProperty("o").PropertyType.GetProperty(aPropertyName[0]));
The error i got is:
Tha parameter MovieType is not bound in the specified Linq to Entities Expression.
I modified it, after i realized that the problem appears too complicated than it is supposed to be.
I got the answer. I realized that the error is popping up for not building the Expression tree properly.
(a) => a.o.MovieType should be understood like two Expressions within one lambda expression.
Hence, the solution should be programmatically something like this:
i.e.