How can I access dynamic properties from the generated LINQ class?
Reason: I would like to be able to customize the displayed columns of the table where Partner is the LINQ class created in the 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 what the method code might look like p.GetProperty(c.Name)
?
Forgive me if the question is very simple, but since I am new to C # and LINQ, I really could not understand.
source
share