【发布时间】:2012-08-07 17:34:14
【问题描述】:
我在静态类中有这样的函数
public static IEnumerable<MyObject> getFilteredList(int docType)
{
var fItems = from i in list
where i.DocType == docType
select i;
return fItems;
}
当我将这个返回的列表用于我的网格中的数据源时,例如:
GridControl.DataSource = staticClass.getFilteredList(10)
Grids DataSource 属性为空。你能解释一下为什么会这样吗?
编辑:列表变量是 List,其中包含 DocType = 10 的元素。 Items 包含元素。
【问题讨论】:
-
那之后你还在使用 databind() 吗?
-
wpf 还是 winforms?形成您将 linq 迭代器分配给数据源的代码,而不是
List。试试添加ToArray()或ToList()是否有帮助。