views:

21

answers:

1

Hello all, I am working on an ASP.net page that also users ChartFX. I need to pull a row from a database table and then flip it so that all of the labels for the row are in a column and all of the data from the row is in a parallel column to the labels.

I would really like to do this using LINQ and then create a table in memory to store these values until I need to use them. What do you all suggest?

A: 

Using method I found at How would I get the column names from a Model LINQ?

var db = new DataContextType();
var members = db.Mapping.MappingSource
                        .GetModel(typeof(DataContextType))
                        .GetMetaType(typeof(TableType))
                        .DataMembers;

var row = …; // select the desired row

var namesAndValues = from member in members
                     select new
                     {
                         Name = member.Name,
                         Value = member.MemberAccessor.GetBoxedValue(row)
                     };
svick
I found a way to get the column names. Once I have the column names I am just going to store everything in a datatable and then use pivot to move the columns to rows. Thanks for the reply.
Jacob Huggart