I am using dynamic LINQ (System.Linq.Dynamic)(you may find description here, http://dynamiclinq.azurewebsites.net/GettingStarted).
The following statement works well
Products.Select("new(ProductName, CategoryID.CategoryName as CategoryName)");
But I accidentally found when CategoryID is null, the results are empty. But I supposed it would return a record such as:
ProductName="Wine", CategoryName="" (or null).
Then I found a way to do so by
Products.Select("new(ProductName, iif(CategoryID==null,\"\",CategoryID.CategoryName) as CategoryName)");
The statement is ugly.
Do you have a better solution?
Thank you in advance,