Linq : filter duplicated line without taking account a column

This question already has an answer here:

  • LINQ's Distinct() on a particular property 17 answers

  • Try this

    var filteredData = data.GroupBy( d=> d.Name).SelectMany(grouping => grouping.First());
    

    Depending upon LinqProvider for the database (IQueryable implementation), The query may run on database, or on client side( if so, there will be memory/network bandwidth issues).

    In some case, not all Linq constructs are supported.


    Try:

    datatable.GroupBy(x => x.Name);

    you need to add a using for the System.Linq namespace.

    链接地址: http://www.djcxy.com/p/51316.html

    上一篇: CSV字符串处理

    下一篇: Linq:过滤重复的行而不考虑列