-2

Currently have the below code which upon compilation creates an anonymous list. I need to convert that to a standard list type preferably a dictionary. I can't find anything online to do so.

_dbService.GetAllOrN().Select(x => new { x.Id, x.Name});
Jack Tyler
  • 509
  • 6
  • 18

1 Answers1

2

LINQ has ToDictionary. You could do that instead of calling Select.

.ToDictionary(x => x.Id, x => x.Name);
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445