0

Is it possible with LINQ to do a cross tab query to add new columns? These columns come from a second and third table and need to be converted to JSON to be displayed in a Telerik table.

One table contains the name of the columns that need to be displayed and the other contains the value for the rows of each column, and this relates to the first table, which has the main related data.

I have investigated dynamically creating the extra columns, but also come unstuck as they need to go through JSON serialization, as well as the difficulties of creating new properties within any class dynamically.

Any ideas would be helpful.

Regards

Mark

McGarnagle
  • 101,349
  • 31
  • 229
  • 260
Mark Naber
  • 63
  • 2
  • 12

1 Answers1

0

I hope this helps, although I'm not sure I understand completely what you're asking ...

Since you're serializing to JSON anyway (and so presumably are not overly concerned with schema/type info), I would suggest just using a Dictionary and populating your data that way. It sounds like you could run some kind of nested loop, cycling through the column names from the one table, and pulling the values from each column from the second table.

EDIT

BTW, it is possible to do dynamic properties using System.ComponentModel, although this seems like overkill from how you described your scenario (you don't require data binding, for instance). Here's a good post on SO, if you're interested: Data binding dynamic data

Community
  • 1
  • 1
McGarnagle
  • 101,349
  • 31
  • 229
  • 260