locked
lambda expression RRS feed

  • Question

  • User-1651183775 posted

    Hello,

    I want to build dynamic lambda expression like this: x=> x.ID.

    From one of the posts i could so far build x => x.Id >= 3. Can someone help me to achieve x=> x.ID using code below:

    var parameter = Expression.Parameter(typeof(Person), "x");
                    var member = Expression.Property(parameter, "Id"); //x.Id
                    var constant = Expression.Constant(3);
                    var body = Expression.GreaterThanOrEqual(member, constant); //x.Id >= 3
                    var finalExpression = Expression.Lambda<Func<Person, bool>>(body, param); x => x.Id >= 3


    </div>

    Wednesday, January 31, 2018 11:37 AM