I'm using Dynamic Expression API (System.Linq.Dynamic
) with Linq to Entities. My linq statement is below.
var query = this.db.Products.AsQueryable()
.Where(strCondition)
.OrderBy("ProductNumber")
.Select("new(ProductNumber, ProductDescription, ProductCategory.Name)");
Now that I have the "query", I don't know how to get the value of each of the field.
string strTemp;
foreach (var item in query)
{
strTemp = item.?
}
It's anonymous type so I can't really use strongly type to get the value. What can I do? The reason I select to get anonymous type fields is because I need to get ProductCategory.Name field into the result. Is there a better way to get ProductCategory.Name in the result with Dynamic Expression API? Can anyone help?