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 8891273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:41:55+00:00 2026-06-14T22:41:55+00:00

I wanted to transform the string Employee.Orders.OrderID in the linq expression : employee.Orders.Select(order =>

  • 0

I wanted to transform the string “Employee.Orders.OrderID” in the linq expression: “employee.Orders.Select(order => order.OrderID)“.

I already know how to do this in simple properties such as “Employee.FirstName” my question is how to do this in properties within a type within a collection.

“Order” is a collection of orders in the class “Employee”.
“OrderID” is a property of the class “Order”.

In other words, I want to transform this;

string path = "Employee.Orders.OrderID";

Into this;

Expression<Func<Employee, object>> exp = employee => employee.Orders.Select(order => order.OrderID);
  • 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-06-14T22:41:56+00:00Added an answer on June 14, 2026 at 10:41 pm

    This should do the trick:

    https://gist.github.com/4149424

    I haven’t compiled the resulting expression, but it builds the expression without an exception.

    EDIT: I’ve added a line to create the lambda and compile it too, which it does, so it works.

    It handles your scenario where you access a property of a collection Orders.OrderID, which is the part that makes it sort of complicated. Without it, it would be about 30 lines shorter.

    Currently, what it does is split the string on ‘.’ and then it recursively processes every element. If the element is IEnumerable (but not a string) it builds an additional Select lambda.

    It also handles a slightly more complex (but more of the same) scenario where you access a collection property in a collection property.

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

Sidebar

Related Questions

I'm using PHP's preg_replace, and trying to transform the string abcd into (a(b(c(d)))) This
Wanted to know if there was a way one could query shelveset details from
Wanted to know if someone had a suggestion on code or maybe there's a
just wanted to ask where I define initial class properties? From other languages I
I wanted to know about Data Type implementation in PHP so I need a
I wanted to know that if I am doing correctly, regarding retain and release
I created a regular expression that reads a string and transforms found url's into
How can I transform a string into a regex string, properly escaping all regex-specific
Just wanted to verify some thought regarding split function. I have constructed a simple
Wanted to see if anyone knows how to add props to a image with

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.