views:

572

answers:

0

Hi,

I have a situation where I would like to create a dynamic LINQ query where the fields are generated on the fly.

following code snippet show what I am trying to achieve.

First query is a standard LINQ query on objects.

Second query is a Dynamic LINQ query on objects.

Second query fail at "Selected = false", and "(string)rb.UserDefineFields.Fields['F2']"

i am wondering is there a way I can walk around this??....somehow make it work? thanks,

var filterColumn = from rb in result
                           select new { rb.FIELD1, UserDefineFields.Sample , Field2 = (string)rb.UserDefineFields.Fields["F2"], Selected = false };

var filterColumn2 = result.AsQueryable().Select("new (FIELD1, UserDefineFields.Sample, (string)rb.UserDefineFields.Fields['F2'], Selected = false )");