I have a collection of classes and each class in the collection has three properties but need to distinct by two of the properties on the collection of classes. The confusing part is that I need all three properties after I distinct by only two of the properties. Most distinct by examples say to create an anonamous type using the properties you want to distinct by but that would get rid of my third property which I need to be in the collection of items after the distinct operation. How do I distinct by two of the three properties but the final result be a collection of the classes containing all three properties? Class is:
public class Foo
{
public int PropertyOne {get; set;}
public int PropertyTwo {get; set;}
public string PropertyThree {get; set;}
}
// fake example of what I want but
// final result has all three properties in the collection still
var finalResult = allItems.DistinctBy(i => i.PropertyOne, i.PropertyTwo).ToArray();
Thanks for any help!