I have a Queryable<Foo> and a List<Bar>. I'm already able to map which books are related to which Authors using LINQ.
I would like to use values of the Bar and dynamically add properties to the Foo object as shown below, obviously changing the type to object or dynamic.
Is this possible with LINQ, and if so, how can I do it?
Sample Desired Result (eventually parsed to JSON)
{
"Id" : 1,
"Name" : "John Doe",
"Garden" : 7,
"Pilot" : 4
}
Sample Classes
public class Foo
{
public int Id { get; set; }
public string Name { get; set; }
}
public class Bar
{
public string Title { get; set; }
public int Count { get; set; }
}