Click here to Skip to main content
15,894,316 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 a data as follows:
Sr.no Name Surname
1 Harsh raut
2 Harsh raut
3 john cena

I am getting the distinct records that is Harsh raut but i cant get john cena .i want that records too.Kindly advice
I wrote a LINQ expression in which i am getting the distinct record for duplicate but except duplicates records i want others too.What changes i need to do in my LINQ Statement.
private IEntityCollectionBase RemoveZteBbhDuplicats(IEntityCollectionBase zteBbhRecords, IFileLog fileLog) {

string[] distinctRecord = zteBbhRecords.Cast<IZteBbh>().Select(zteBbh => (zteBbh.CombinedMaster as ICombinedMaster).ToString()).GroupBy(items => items).Where(items => items.Count() > 1).Select(items => items.Key).Distinct().ToArray();}


Thanks
Harshal
Posted
Updated 22-May-14 3:02am
v2

see here[^]
 
Share this answer
 
C#
var distinctData = (from g in context.TableName

select g).ToList().Distinct();
 
Share this answer
 
remove the where condition

C#
string[] distinctRecord = zteBbhRecords.Cast<iztebbh>().Select(zteBbh => (zteBbh.CombinedMaster as ICombinedMaster).ToString()).GroupBy(items => items).Select(items => items.Key).Distinct().ToArray();
 
Share this answer
 
v2
Comments
King Fisher 22-May-14 9:05am    
Can you look this
http://www.codeproject.com/Questions/774153/How-Do-I-Solve-System-Invalidcastexception-Specifi
R Harshal 22-May-14 10:05am    
Thanks Buddy
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