I am using the Dynamic Expression API ( System.Linq.Dynamic) with LINQ to Entities. My LINQ request is below.
var query = this.db.Products.AsQueryable()
.Where(strCondition)
.OrderBy("ProductNumber")
.Select("new(ProductNumber, ProductDescription, ProductCategory.Name)");
Now that I have a query, I don’t know how to get the value of each of the fields.
string strTemp;
foreach (var item in query)
{
strTemp = item.?
}
This is an anonymous type, so I cannot use strongly the type to get the value. What can I do? The reason I choose to receive anonymous type fields is because I need to get the ProductCategory.Name field as a result. Is there a better way to get ProductCategory.Name as a result using the Dynamic Expression API? Can anyone help?
source
share