Entity Framework select distinct name

前端 未结 8 1927
小蘑菇
小蘑菇 2020-12-12 14:18

How can I do this SQL query with Entity Framework?

SELECT DISTINCT NAME FROM TestAddresses
8条回答
  •  盖世英雄少女心
    2020-12-12 14:33

    The way that @alliswell showed is completely valid, and there's another way! :)

    var result = EFContext.TestAddresses
        .GroupBy(ta => ta.Name)
        .Select(ta => ta.Key);
    

    I hope it'll be useful to someone.

提交回复
热议问题