I’m trying to print a list of DTO objects to a Console statement. I am grabbing a list of objects by category name (PK) from SQL server and converting them to DTO’s to pass to the client. I should elaborate… Each object (in the object table) has a category along with some other strings, the Category table’s PK is ‘CategoryName’
Here is an example of my code:
foreach(Object ii in context.Objects.Where(i => i.Commodity.CategoryName == categoryName))
{
ObjectDTO objectDTO = EncodeDTO.BuildObjectDTO(ii);
lotDTOList.Add(ii);
}
I tried using:
//for testing
objectDTOList.ForEach(Console.WriteLine);
return objectDTOList;
You can do that like this:
Remember to override ToString() to get meaningful output, or alternatively do something like: