in C# using linq i have a query like:
var result = from p in cart select new { p.Product.Title, p.Product.Price };
now i want to add some another items to result. For example adding:
int weight;
string message;
so that i can have something like:
foreach( var r in result)
{
dosomething(r.weight;)
dosomething(r.message);
dosomething(r.title);
dosomething(r.price);
}
is it possible? how should i do it?
You can’t do that. Anonymous types are normal types and they are fixed at compile time. You can’t change them later.
EDIT:
You can create a container class for your result set and then select based on that:
class MyResult
And then you can use:
Later you could do: