【问题标题】:System.Collections.Generic.List<ActualEstimatation.frmEstimate.ItemInfo>' does not contain a definition for 'Where'System.Collections.Generic.List<ActualEstimatation.frmEstimate.ItemInfo>' 不包含“Where”的定义
【发布时间】:2013-07-02 09:04:53
【问题描述】:

我正在尝试动态绑定树视图。

我在 Google 中搜索并找到了一些不错的链接。

当我尝试在我的系统中运行时,它会显示类似这样的错误

'System.Collections.Generic.List<ActualEstimatation.frmEstimate.ItemInfo>' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'System.Collections.Generic.List<ActualEstimatation.frmEstimate.ItemInfo>' could be found (are you missing a using directive or an assembly reference?)

这些链接是 How to dynamically populate treeview (C#)

和 sga101 的解决方案 How to insert Datas to the Winform TreeView(C#) in effitive coding?

我在谷歌上搜索解决了上述问题,但没有找到任何解决方案。

请帮我解决这个问题。

提前致谢

【问题讨论】:

  • 您使用的是 .net framework 3.5 或更高版本吗?
  • 是的,我使用的是 .net Framework3.5
  • Enumerable.Where() 是一个扩展方法。将using System.Linq; 放在源代码文件的顶部。

标签: winforms treeview


【解决方案1】:

我需要查看更多您的代码,但我相信您缺少的是 LINQ 语句。 here 您可以阅读它并开始了解如何在您的应用程序中实现。

例如:

using (ServiceContext svcContext = new ServiceContext(_serviceProxy))
{
   var query_where1 = from a in svcContext.AccountSet
                where a.Name.Contains("Contoso")
                select a;
   foreach (var a in query_where1)
   {
    System.Console.WriteLine(a.Name + " " + a.Address1_City);
   }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多