I wonder how can I achieve this?
I want to get only different names from the collection of objects
MyObject a = new Object(); a.Name = 'One'; a.Value = '10'; MyObject b = new Object(); b.Name = 'One'; b.Value = '15'; MyObject c = new Object(); c.Name = 'Two'; c.Value = '10';
So, I want to return only the name. I'm not interested in the meaning in this case, just the name.
So i tried
// add all objects to the collection.
myCollection.Disinct()..Select(x => new MyClassToStore() {Text = x.Name, Value = x.Name}).ToList());
However, I need to make a distinction at the property level not at the object level. Therefore, I want to return "One" and "Two." Right now I'm getting One, One, and Two back.
I see a library called morelinq , but I'm not sure if I will use it since it is still in beta and does not seem to be developed for more.
Plus an entire library for a single retrieval request. I'm not sure if itβs worth it.
source share