救命! Linq查询

时间:2009-10-29 14:04:49

标签: linq

我收到关于单词记录的错误消息 - 找不到类型或命名空间。请帮忙调试一下,缺少什么?

 if (ProjDDL1.SelectedItem.Value != "--") results = CustomSearch<Records>(results, s => s.Business == ProjDDL1.SelectedItem.Value); 

Method CustomSearch:

 private DataTable CustomSearch<TKEY>(DataTable dt, Func<Records, bool> selector)
{
    DataTable results = (dt.AsEnumerable().Where(selector).CopyToDataTable());
    return results;
}

2 个答案:

答案 0 :(得分:0)

Visual Studio通常会为编译时出错的项加下划线。如果单击它并按Shift-Alt-F10,它将允许您自动将命名空间添加到代码中。如果您没有得到建议,这意味着您没有引用它所需的DLL。

答案 1 :(得分:0)

好吧,如果它不知道Records的含义,请查看您的引用并使用指令。哪个命名空间是Records类型?

为什么您的CustomSearch方法仍然是通用的?它似乎没有在任何地方使用TKEY ...