I have a collection of "product" objects that each contain a collection of benefit objects. See below:
<Products>
<Product ID="454">
<ProductName>Economy</ProductName>
<Benefits>
<Benefit>
<Name>Medical</Name>
<Value>5000000</Value>
<Excess>100</Excess>
</Benefit>
<Benefit>
<Name>Emergency</Name>
<Value>350</Value>
<Excess>100</Excess>
</Benefit>
</Product>
</Products>
I'm trying to create a LINQ query to get the "Medical" benefit value for product "454":
<%: Model.Products.Where(x => x.ProductId == "454").SelectMany(p => p.Benefits).Where(b => b.Name == "Medical").Select(v => v.Value.ToString()) %>
However this just returns:
System.Linq.Enumerable+WhereSelectEnumerableIterator`2[Domain.Entities.Benefit,System.String] System.Linq.Enumerable+WhereSelectEnumerableIterator`2[Domain.Entities.Benefit,System.String] System.Linq.Enumerable+WhereSelectEnumerableIterator`2[Domain.Entities.Benefit,System.String] System.Linq.Enumerable+WhereSelectEnumerableIterator`2[Domain.Entities.Benefit,System.String
How do I get it to return the actual value I'm after?