Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Team,

Nice to see you all. I have written the query in LINQ Expression.
I want to modify that query in Select distinct LINQ expression,is it possible .please Guide ME.The Query is as follows:

string[] matchID = zteBbhRecords.Cast<IZteBbh>().Select(zteBbh => (zteBbh.CombinedMaster as ICombinedMaster).CellId.ToString()).GroupBy(item => item).Where(items => items.Count() > 1).Select(item => item.Key).ToArray();
Posted

1 solution

So, using Distinct().ToArray(), we can easily get the distinct values and convert them to array.
string[] matchID = zteBbhRecords.Cast<IZteBbh>()
         .Select(zteBbh => (zteBbh.CombinedMaster as ICombinedMaster)
             .CellId.ToString()).GroupBy(item => item)
             .Where(items => items.Count() > 1)
             .Select(item => item.Key).Distinct().ToArray();
 
Share this answer
 
v2
Comments
R Harshal 16-May-14 6:19am    
Thanks Brother .
its working .Thanks A lot.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900