Global.asax中的dataTable.AsEnumerable()

时间:2012-10-26 05:27:04

标签: c# asp.net

Application_Start我试图过滤数据表。在文件后面的其他代码中,我可以使用DataTable的AsEnumerable();但不是在Global.asax中。任何原因?

1 个答案:

答案 0 :(得分:0)

我在Global.asax

的文件后面单独编写代码

的Global.asax:

<%@ Application Codebehind="Global.asax.cs" Language="C#" %>

的Global.asax.cs:

public class Global : HttpApplication
{

    void Application_Start(object sender, EventArgs e)
    {
        ....
        var filtered = from entity in dt.AsEnumerable()
                       .Where(entity => entity.Field<int>("SerialNumber") == key)
                       select entity;

        ....
    }
    ....
}