LINQ: Distinct values

Are you trying to be distinct by more than one field? If so, just use an anonymous type and the Distinct operator and it should be okay: var query = doc.Elements(“whatever”) .Select(element => new { id = (int) element.Attribute(“id”), category = (int) element.Attribute(“cat”) }) .Distinct(); If you’re trying to get a distinct set of values … Read more

LINQ Select Distinct with Anonymous Types

Have a read through K. Scott Allen’s excellent post here: And Equality for All … Anonymous Types The short answer (and I quote): Turns out the C# compiler overrides Equals and GetHashCode for anonymous types. The implementation of the two overridden methods uses all the public properties on the type to compute an object’s hash … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)