在此代码中出错:
var distinctDateValues = dt.AsEnumerable()
.Select(row => DateTime.Parse(row.Field<string>("DATE")))
.Distinct()
.OrderByDescending(x => x)
.ToList();
Run Code Online (Sandbox Code Playgroud)
'System.Data.EnumerableRowCollection'不包含'Distinct'的定义,并且没有扩展方法'Distinct'接受类型'System.Data.EnumerableRowCollection'的第一个参数可以找到(你是否缺少using指令或程序集引用?)
我在我的CLR程序中使用此代码.请建议我如何添加dll.添加引用时,它不会在SQL引用选项卡中显示System.Linq.
编辑:我正在使用3.5框架和Visual Studio 2010 CLR项目
System.Core在项目中包含参考
和
导入System.Linq代码.
附加说明:
根据我的回答评论,大多数人会认为在这种情况下Select也行不通.但事实并非如此.
Select来自System.Data.EnumerableRowCollectionExtensions哪里Distinct来自System.Linq.Enumerable.
