Select Into A Dictionary With LINQ
June 9, 2014
This is neat, instead of doing it the long way, if you need to pull your data into a dictionary, you can do it like this:
Dictionary<string, int> facilityNpis = db.Facilities.Where(c => c.NPI.Trim().Length > 0).Select(a => new { a.NPI, a.ID }).AsEnumerable().ToDictionary(b => b.NPI, b => b.ID);
No comments yet