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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:56:35+00:00 2026-05-18T06:56:35+00:00

My expression aren’t great and I would like to improve on them so I

  • 0

My expression aren’t great and I would like to improve on them so I am wondering if someone could explain for me if it possible to create a property in a class that can be given a value during instantiation like this:

new Column<Product>{ ColumnProperty = p => p.Title};

or better still (but I think I am pushing it)

new Column {ColumnProperty = p => p.Title};

with a class something like this:

public class Column<TModel>
{
        public Expression<Func<TModel, TProperty>> ColumnProperty { get; set; }
}

The basic idea behind it is that I create a Grid from a bunch of Column objects something like this.

List<Product> productList = GetProductsFromDb();
List<Column> columnList = new List<Column>();

columnList.Add(new Column<Product> {ColumnProperty = p => p.ProductId, Heading = "Product Id"});
columnList.Add(new Column<Product> {ColumnProperty = p => p.Title, Heading = "Title"});

Grid myGrid = new Grid(productList, columnList);

This may not be the tidiest/easiest way to do this but I am interested in knowing whether it can be done as I want to improve my understanding of expressions and I love being able to have strongly typed values instead of string literals it’s so much nicer to work with.

Any thoughts, ideas, ramblings would be greatly appreciated

Cheers
Rob

  • 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-18T06:56:36+00:00Added an answer on May 18, 2026 at 6:56 am

    When you define something like Func<TModel, TProperty> it means there is a method that takes a TModel type and returns a TProperty type. So lambda expressions like

    p => p.ProductId 
    

    returns the value of the property rather than the property itself.

    What you can do to make this syntax work is to define your ColumnProperty as follows:

    public Expression<Func<TModel, object>> ColumnProperty { get; set; }
    

    Then you can extract detailed information from the expression tree.

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

Sidebar

Related Questions

I would like to construct a regular expression that matches any letter (including accented
I got the following Expression that can look like this (the amount of Sqrt[XXX]
Regular expressions are great for text editing. But sometimes they aren't quite enough. For
I'm wondering if Python has anything like the C# anonymous classes feature. To clarify,
I'm doing an expression valuation program, just like this . My problem is that
I've just stumbled upon some cryptic sed expression in a legacy script. Could you
I would like to match strings like this: page page01-page02 page01-page02-page03 page-page/page/page-03-001 p-a-g-e p/a/g/e
Expression Blend + SketchFlow provides a template for Windows Phone rapid application prototyping which
Expression design has a feature called Skeleton strokes which allows you to use arbitrary
Regualar expression: <img[^>]+src\s*=\s*[']([^']+)['][^>]*> This works fine when 'src' is in lowercase and manages both

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.