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

  • Home
  • SEARCH
  • 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 109941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:08:56+00:00 2026-05-11T02:08:56+00:00

How can I access dynamically properties from a generated LINQ class ? Cause I

  • 0

How can I access dynamically properties from a generated LINQ class ?

Cause I would like to be able to customize the displayed table columns where Partner is the LINQ Class generated from a SQL Server Database Table.

<table class='grid'>   <thead>    <tr>      <% foreach (Column c in (IEnumerable)ViewData['columns']) { %>      <th><%= c.Title %></th>          <% } %>                                   </tr>  </thead>  <tbody>  <% foreach (Partner p in (IEnumerable)ViewData.Model) { %>    <tr>      <% foreach (Column c in (IEnumerable)ViewData['columns']) { %> ?????   <th> <%= p.GetProperty(c.Name) %>  </th>  ?????      <% } %>             </tr>         <% } %>   </tbody> </table> 

Any idea how the code of the p.GetProperty(c.Name) method could look like ?

Forgive me if the Question is very simple but as I’m new to C# and LINQ I really couldn’t figure it out.

  • 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. 2026-05-11T02:08:56+00:00Added an answer on May 11, 2026 at 2:08 am

    Reflection is a pretty good fit here, but really – everything is known at compile time. So it’s possible to specify everything at design time.

    public class DataItem {   string Title {get;set;}   object Value {get;set;} }  public interface IDataItems {   IEnumerable<DataItem> Items() }   //suppose LINQ gives you this: public partial class Customer {   public string Name {get;set;}   public string Address {get;set;}   public int Age {get;set;} }  //then you add this in another file. //if there's a lot of this, it can be code genned by design-time reflection public partial class Customer : IDataItems {   public IEnumerable<DataItem> IDataItems.Items()   {     yield return new DataItem() {'Name', Name};     yield return new DataItem() {'Address', Address};     yield return new DataItem() {'Age', Age};   } }  //and the foreach loops look like this: foreach(DataItem d in ViewData.OfType<IDataItems>().First().Items()) {   d.Title; }  foreach(IDataItems container in ViewData.OfType<IDataItems>()) {     foreach(DataItem d in container.Items())     {        d.Value;     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 64k
  • Answers 64k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I suggest using the stretch method they recommend for button… May 11, 2026 at 10:46 am
  • added an answer You can mark the xml files as resources, and they… May 11, 2026 at 10:46 am
  • added an answer If the variables are declared in request or page scope,… May 11, 2026 at 10:46 am

Related Questions

How can I access dynamically properties from a generated LINQ class ? Cause I
How can I dynamically load a usercontrol in ASP.NET if I dont have access
How can I access a public static member of a Java class from ColdFusion?
How can I access UserId in ASP.NET Membership without using Membership.GetUser(username) in ASP.NET Web
How can I access options that I set in a jQuery Datepicker? $(#testDatePicker).datepicker({ minDate:
How can I access Ethernet statistics from C/C++ code like netstat -e ? Interface
How can I access Class object for Generics? Currently, I am doing it this
Preferably in VB.Net, but C# is fine, how can I access the extra properties
How can I programmatically determine if I have access to a server (TCP) with
How can I get programmatic access to the call stack?

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.