Microsoft
Software
Hardware
Network
Question : Linq Distinct
I am having some trouble with Linq on a Distinct. I have a list of custom objects as defined below, and I need to get a list of the distinct entries values. How do I get it to work? I think I just need how to implement the Distinct(comparer).
internal class FirstXTimeDoc : IEqualityComparer
meDoc>
{
public string Article;
public DateTime ArticleDate;
#region IEqualityComparer
meDoc> Members
bool IEqualityComparer
meDoc>.Equ
als(FirstX
TimeDoc x, FirstXTimeDoc y)
{
return (x.Article == y.Article && x.ArticleDate == y.ArticleDate);
}
int IEqualityComparer
meDoc>.Get
HashCode(F
irstXTimeD
oc obj)
{
throw new NotImplementedException();
}
Answer : Linq Distinct
this should work
1:
IEnumerable
distinctNames = yourListOfObjects.Select(x => x.Name).Distinct();
Open in New Window
Select All
Random Solutions
Keeping dropdown list state
Remove special character from string
Connecting a remote server (Windows 2000) to a remote main server (Windows 2003 Standard)
dd & flar create : syntax to use with pipe (|), gzip & ssh needed
PerformancePoint error - Cannot connect to data source
How do I use a user-defined function in Access
InfoPath 2007: Error on file open, "InfoPath cannot create a new, blank form"
programmatically work with object data source and report viewer
SharePoint Services Site Image
Disappearing Appointments in Exchange 2007, Outlook 2007 mailboxes