error方法'System.Linq.Enumerable的类型参数。 [英] error The type arguments for method 'System.Linq.Enumerable.

查看:266
本文介绍了error方法'System.Linq.Enumerable的类型参数。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我编写的代码如下:在group by子句中,我想按CellId分组。

Hi Everyone,

I have written the code as follows:In group by clause i want to group by CellId.

if (zteBbhRecords.Count > 0)
                           {
                               zteBbhRecords.Cast<IZteBbh>().Select(zteBbh => (zteBbh.CombinedMaster as ICombinedMaster).CellId.ToString()).GroupBy((zteBbhEntity.CombinedMaster as ICombinedMaster).CellId).Where(items => items.Count() > 1).Select(item => item.Key).Distinct().ToArray();
                           }









我收到的错误是如下:





I am getting the error as follows:

Error	19	The type arguments for method 'System.Linq.Enumerable.GroupBy<TSource,TKey>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,TKey>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.	F:\Quantum India\New Projects\Kaizen\Code\Kaizen.Application\Kaizen.Application.2G\Kaizen.Application.2G.DataManagers\ZteBbhDataManager.cs	218	33	Kaizen.Application.Kaizen2G.DataManagers





请协助。

谢谢

Harshal



Please kindly assist .
Thanks
Harshal

推荐答案

嗨R Harshal,



Group By运算符不能用作你使用它的方式。简单地放置演员阵容不起作用(这就是你在这里做的事情 -
Hi R Harshal,

The Group By operator cannot be used as the way you are using it. Simply putting the cast doesnot work (This is what you are doing here -
GroupBy((zteBbhEntity.CombinedMaster as ICombinedMaster).CellId)

相反它应该像

GroupBy(cells =>(zteBbhEntity.CombinedMaster as ICombinedMaster).CellId)

.Group By有8个Overloads,深入了解你可以参考以下链接 - http://msmvps.com/blogs/jon_skeet/archive/2011/ 01/01 / reimplementing-linq-to-objects-part-21-groupby.aspx [ ^ ]

. Group By has 8 Overloads and for deep insight you can refer the following link - http://msmvps.com/blogs/jon_skeet/archive/2011/01/01/reimplementing-linq-to-objects-part-21-groupby.aspx[^]


这篇关于error方法'System.Linq.Enumerable的类型参数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆