我可以使用Linq迭代/过滤我的web.config AppSettings吗?

Pur*_*ome 7 linq asp.net appsettings

我试图找出如何使用Linq从我的web.config文件中过滤掉一些我的appsettings.

我正在尝试执行以下操作(语法错误): -

var query = from q in System.Web.Configuration.WebConfigurationManager.AppSettings.Keys
            where q.StartsWith("Foo")
            select q);
Run Code Online (Sandbox Code Playgroud)

我做错了什么?

编辑:添加screenie(这是一个链接)

alt text http://img21.imageshack.us/img21/5516/errorji.png

DSO*_*DSO 9

如果您想要值,请尝试以下操作:

var settings = System.Web.Configuration.WebConfigurationManager.AppSettings;

var query = from string q in settings.Keys
            where q.StartsWith("Foo")
            select settings[q];
Run Code Online (Sandbox Code Playgroud)