using System.Collections.Generic;
using System.Linq.Expressions;
public string Name {get;set;}
private static List<MyKVP> list = new List<MyKVP>{
new MyKVP{ID = 1, Name = "test1"},
new MyKVP{ID = 1, Name = "test1"},
new MyKVP{ID = 2, Name = "test2"},
new MyKVP{ID = 2, Name = "test2"},
new MyKVP{ID = 3, Name = "test3"}
public static void Main()
var x = list.Distinct(z => z.ID);
Console.WriteLine(y.Name);
internal static class EFExtensions
public static IEnumerable<T> Distinct<T>(this IEnumerable<T> source, Expression<Func<T, object>> prop)
return source.GroupBy(prop.Compile()).Select(g => g.First());