Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7047097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:43:46+00:00 2026-05-28T02:43:46+00:00

Supposing I have the following LambdaExpression: var itemParam = Expression.Parameter(typeof(Thing), thing); var someValue =

  • 0

Supposing I have the following LambdaExpression:

var itemParam = Expression.Parameter(typeof(Thing), "thing");
var someValue = "ABCXYZ123"; // value to compare

LambdaExpression lex = Expression.Lambda(
  Expression.Equal(
    Expression.Property(itemParam, "Id"), // I want ID to be a Body expression parameter
    Expression.Constant(someValue)
  ), itemParm);

And I want the property name (2nd parameter) in the Expression.Property(…) factory to be a parameter, how do I go about doing this?

I was hoping to see a constructor that looks like this, but it doesn’t exist:

Expresssion.Property(Expression instance, Expression propName)

Is there some trick I can pull that can convert a parameterized ConstantExpression into the needed string or MemberInfo? Maybe I’m going about this the wrong way.

My hunch is that because these expression trees, when compiled, become lightweight IL, that member access information is required, thus, the names of members and properties must be provided when constructing expression trees.

Thanks for any tips!!

EDIT: Wanted to add that this will be used as an argument to the Enumerable.Where(…) extension method for determining a match on a relationship between two classes / entities.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:43:47+00:00Added an answer on May 28, 2026 at 2:43 am

    Expression trees represent IL structures that are roughly of the same kind that you see in your C#/VB.NET programs. You cannot parameterize that property expression for the same reason that you cannot “parameterize” the following code:

    var x = new MyClass {Id = 1, Name = "hello"};
    var propName = "Id";
    var xId = x.propName; // <-- This will not compile
    

    If you need to implement this functionality, and your expression trees are not passed to IQueryable<T>, you can write a helper function taking an object and a string, and returning value of that object’s property identified by the string; then you can use Expression.Call to invoke that helper function into the expression tree that you are building.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What's the object type returned by Datepicker? Supposing I have the following: $(#txtbox).datepicker({ onClose:
Supposing I have the following script <div id=something> <?php // execute a loop ?>
Supposing I have the following type from an external library: union foreign_t { struct
Supposing I have the following text: Lorem ipsum dolor sit amet, consectetur adipisicing elit,
Supposing I have the following: module A class B # ... end # ...
I have tried to use the following regex expression to remove html whitespace and
Supposing I have the following public class Foo { private Map<Integer,SomeObject> myMap; public Foo()
Supposing I have the following action: def index @posts = Post.joins(:tags).where(:tags => {:id =>
supposing I have the following data: id name source ----------------- 1 'n' 'a' 1
Supposing I have the following list: A | B | C | D or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.