How can I convert IEnumerable to List in C#?

前端 未结 5 1813
被撕碎了的回忆
被撕碎了的回忆 2020-12-29 07:14

I am using LINQ to query a generic dictionary and then use the result as the datasource for my ListView (WebForms).

Simplified code:

Dictionary

        
5条回答
  •  情话喂你
    2020-12-29 08:04

    Just adding knowledge the next sentence doesn´t recover any data from de db. Just only create the query (for that it is iqueryable type). For launching this query you must to add .ToList() or .First() at the end.

    dict.Values.Where(rec => rec.Name == "foo")
    

提交回复
热议问题