By Patrick Desjardins


2009-01-28 20:45:09 8 Comments

I am playing with LINQ to learn about it, but I can't figure out how to use Distinct when I do not have a simple list (a simple list of integers is pretty easy to do, this is not the question). What I if want to use Distinct on a list of an Object on one or more properties of the object?

Example: If an object is Person, with Property Id. How can I get all Person and use Distinct on them with the property Id of the object?

Person1: Id=1, Name="Test1"
Person2: Id=1, Name="Test1"
Person3: Id=2, Name="Test2"

How can I get just Person1 and Person3? Is that possible?

If it's not possible with LINQ, what would be the best way to have a list of Person depending on some of its properties in .NET 3.5?

21 comments

@uguronline 2019-08-23 13:07:53

    List<string> colors = new List<string> { "blue", "red", "black", "blue", "yellow", "blue" };
    IEnumerable<string> distinctColors = colors.Distinct();

@Dharman 2019-08-23 13:09:23

While this code may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please edit your answer to add explanations and give an indication of what limitations and assumptions apply.

@Harry .Naeem 2019-03-27 06:04:44

You can use DistinctBy() for getting Distinct records by an object property. Just add the following statement before using it:

using Microsoft.Ajax.Utilities;

and then use it like following:

var listToReturn = responseList.DistinctBy(x => x.Index).ToList();

where 'Index' is the property on which i want the data to be distinct.

@karcsi 2012-02-14 12:52:51

Use:

List<Person> pList = new List<Person>();
/* Fill list */

var result = pList.Where(p => p.Name != null).GroupBy(p => p.Id).Select(grp => grp.FirstOrDefault());

The where helps you filter the entries (could be more complex) and the groupby and select perform the distinct function.

@DavidScherer 2019-03-11 13:19:44

Perfect, and works without extending Linq or using another dependency.

@Waldemar Gałęzinowski 2018-09-27 20:31:34

Override Equals(object obj) and GetHashCode() methods:

class Person
{
    public int Id { get; set; }
    public int Name { get; set; }

    public override bool Equals(object obj)
    {
        return ((Person)obj).Id == Id;
        // or: 
        // var o = (Person)obj;
        // return o.Id == Id && o.Name == Name;
    }
    public override int GetHashCode()
    {
        return Id.GetHashCode();
    }
}

and then just call:

List<Person> distinctList = new[] { person1, person2, person3 }.Distinct().ToList();

@Oleg Skripnyak 2018-10-28 05:30:11

However GetHashCode() should be more advanced (to count also the Name), this answer is probably best by my opinion. Actually, to archive the target logic, there no need to override the GetHashCode(), Equals() is enough, but if we need performance, we have to override it. All comparison algs, first check hash, and if they are equal then call Equals().

@Oleg Skripnyak 2018-10-28 05:48:19

Also, there in Equals() the first line should be "if (!(obj is Person)) return false". But best practice is to use separate object casted to a type, like "var o = obj as Person;if (o==null) return false;" then check equality with o without casting

@B2K 2019-07-10 21:17:49

Overriding Equals like this is not a good idea as it could have unintended consequences for other programmers expecting the Person's Equality to be determined on more than a single property.

@Mohamed Hammam 2018-07-16 05:26:30

Please give a try with below code.

var Item = GetAll().GroupBy(x => x .Id).ToList();

@Hearen 2018-07-16 05:46:09

A short answer is welcome, however it won't provide much value to the latter users who are trying to understand what's going on behind the problem. Please spare some time to explain what's the real issue to cause the problem and how to solve. Thank you ~

@cahit beyaz 2017-07-13 08:33:18

Solution first group by your fields then select firstordefault item.

    List<Person> distinctPeople = allPeople
   .GroupBy(p => p.PersonId)
   .Select(g => g.FirstOrDefault())
   .ToList();

@Chuck Rostance 2012-03-06 18:28:50

You could also use query syntax if you want it to look all LINQ-like:

var uniquePeople = from p in people
                   group p by new {p.ID} //or group by new {p.ID, p.Name, p.Whatever}
                   into mygroup
                   select mygroup.FirstOrDefault();

@Max Carroll 2018-01-05 15:57:25

Hmm my thoughts are both the query syntax and the fluent API syntax are just as LINQ like as each other and its just preference over which ones people use. I myself prefer the fluent API so I would consider that more LINK-Like but then I guess that's subjective

@Ryan The Leach 2018-10-02 04:11:01

LINQ-Like has nothing to do with preference, being "LINQ-like" has to do with looking like a different query language being embedded into C#, I prefer the fluent interface, coming from java streams, but it is NOT LINQ-Like.

@Caspian Canuck 2016-08-22 17:45:16

If you don't want to add the MoreLinq library to your project just to get the DistinctBy functionality then you can get the same end result using the overload of Linq's Distinct method that takes in an IEqualityComparer argument.

You begin by creating a generic custom equality comparer class that uses lambda syntax to perform custom comparison of two instances of a generic class:

public class CustomEqualityComparer<T> : IEqualityComparer<T>
{
    Func<T, T, bool> _comparison;
    Func<T, int> _hashCodeFactory;

    public CustomEqualityComparer(Func<T, T, bool> comparison, Func<T, int> hashCodeFactory)
    {
        _comparison = comparison;
        _hashCodeFactory = hashCodeFactory;
    }

    public bool Equals(T x, T y)
    {
        return _comparison(x, y);
    }

    public int GetHashCode(T obj)
    {
        return _hashCodeFactory(obj);
    }
}

Then in your main code you use it like so:

Func<Person, Person, bool> areEqual = (p1, p2) => int.Equals(p1.Id, p2.Id);

Func<Person, int> getHashCode = (p) => p.Id.GetHashCode();

var query = people.Distinct(new CustomEqualityComparer<Person>(areEqual, getHashCode));

Voila! :)

The above assumes the following:

  • Property Person.Id is of type int
  • The people collection does not contain any null elements

If the collection could contain nulls then simply rewrite the lambdas to check for null, e.g.:

Func<Person, Person, bool> areEqual = (p1, p2) => 
{
    return (p1 != null && p2 != null) ? int.Equals(p1.Id, p2.Id) : false;
};

EDIT

This approach is similar to the one in Vladimir Nesterovsky's answer but simpler.

It is also similar to the one in Joel's answer but allows for complex comparison logic involving multiple properties.

However, if your objects can only ever differ by Id then another user gave the correct answer that all you need to do is override the default implementations of GetHashCode() and Equals() in your Person class and then just use the out-of-the-box Distinct() method of Linq to filter out any duplicates.

@Arindam 2016-05-16 10:42:56

List<Person>lst=new List<Person>
        var result1 = lst.OrderByDescending(a => a.ID).Select(a =>new Player {ID=a.ID,Name=a.Name} ).Distinct();

@Amy B 2009-01-29 14:39:07

What if I want to obtain a distinct list based on one or more properties?

Simple! You want to group them and pick a winner out of the group.

List<Person> distinctPeople = allPeople
  .GroupBy(p => p.PersonId)
  .Select(g => g.First())
  .ToList();

If you want to define groups on multiple properties, here's how:

List<Person> distinctPeople = allPeople
  .GroupBy(p => new {p.PersonId, p.FavoriteColor} )
  .Select(g => g.First())
  .ToList();

@Amy B 2012-01-17 12:34:52

@ErenErsonmez sure. With my posted code, if deferred execution is desired, leave off the ToList call.

@Alex KeySmith 2012-05-16 14:14:32

Very nice answer! Realllllly helped me in Linq-to-Entities driven from a sql view where I couldn't modify the view. I needed to use FirstOrDefault() rather than First() - all is good.

@zoltanflavius 2013-04-30 15:12:59

How about calling IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> source, IEqualityComparer<TSource> comparer)?

@Erez Cohen 2014-12-10 18:42:12

Does this always return the first of the "repeating" elements (assuming the list was previously sorted)?

@Amy B 2015-07-13 13:43:06

@ErezCohen yes - the first element encountered in each group will be returned. The documentation of System.Linq.Enumerable.GroupBy makes this clear.

@user585440 2016-01-06 23:38:56

I tried it and it should change to Select(g => g.FirstOrDefault())

@Johny Skovdal 2016-08-29 16:48:23

@DavidB you might want to make a note that for LinqToEntities it should be FirstOrDefault instead. First is not supported. :)

@Naomi 2016-10-10 21:32:50

I tried that approach but it's not working for me. I have a class with multiple properties, I want to return a list of different type (3 properties only) with distinct values. I tried var possibleValues = _matrixTemplateValuesAdapter.GetAll().GroupBy(v => new ValueAttribute { ValueName = v.ValueName, AttributeId = v.AtnameId, Hidden = v.Hidden }).Select(g => g.First()) .ToList(); but it doesn't select distinct new values

@Hulvej 2016-11-23 14:44:47

This should be the real accepted answer IMO. In most cases you would be good with the groupBy. No need for another lib for doing that.

@ChocapicSz 2017-07-17 12:58:48

Wondering if shouldn't have used SingleOrDefault() instead of First().

@Amy B 2017-07-17 13:41:07

@ChocapicSz Nope. Both Single() and SingleOrDefault() each throw when the source has more than one item. In this operation, we expect the possibility that each group may have more then one item. For that matter, First() is preferred over FirstOrDefault() because each group must have at least one member.... unless you're using EntityFramework, which can't figure out that each group has at least one member and demands FirstOrDefault().

@David Fahlander 2015-01-20 15:01:47

You can do this with the standard Linq.ToLookup(). This will create a collection of values for each unique key. Just select the first item in the collection

Persons.ToLookup(p => p.Id).Select(coll => coll.First());

@Vladimir Nesterovsky 2014-07-10 21:00:08

When we faced such a task in our project we defined a small API to compose comparators.

So, the use case was like this:

var wordComparer = KeyEqualityComparer.Null<Word>().
    ThenBy(item => item.Text).
    ThenBy(item => item.LangID);
...
source.Select(...).Distinct(wordComparer);

And API itself looks like this:

using System;
using System.Collections;
using System.Collections.Generic;

public static class KeyEqualityComparer
{
    public static IEqualityComparer<T> Null<T>()
    {
        return null;
    }

    public static IEqualityComparer<T> EqualityComparerBy<T, K>(
        this IEnumerable<T> source,
        Func<T, K> keyFunc)
    {
        return new KeyEqualityComparer<T, K>(keyFunc);
    }

    public static KeyEqualityComparer<T, K> ThenBy<T, K>(
        this IEqualityComparer<T> equalityComparer,
        Func<T, K> keyFunc)
    {
        return new KeyEqualityComparer<T, K>(keyFunc, equalityComparer);
    }
}

public struct KeyEqualityComparer<T, K>: IEqualityComparer<T>
{
    public KeyEqualityComparer(
        Func<T, K> keyFunc,
        IEqualityComparer<T> equalityComparer = null)
    {
        KeyFunc = keyFunc;
        EqualityComparer = equalityComparer;
    }

    public bool Equals(T x, T y)
    {
        return ((EqualityComparer == null) || EqualityComparer.Equals(x, y)) &&
                EqualityComparer<K>.Default.Equals(KeyFunc(x), KeyFunc(y));
    }

    public int GetHashCode(T obj)
    {
        var hash = EqualityComparer<K>.Default.GetHashCode(KeyFunc(obj));

        if (EqualityComparer != null)
        {
            var hash2 = EqualityComparer.GetHashCode(obj);

            hash ^= (hash2 << 5) + hash2;
        }

        return hash;
    }

    public readonly Func<T, K> KeyFunc;
    public readonly IEqualityComparer<T> EqualityComparer;
}

More details is on our site: IEqualityComparer in LINQ.

@gcoleman0828 2013-10-21 00:47:18

The best way to do this that will be compatible with other .NET versions is to override Equals and GetHash to handle this (see Stack Overflow question This code returns distinct values. However, what I want is to return a strongly typed collection as opposed to an anonymous type), but if you need something that is generic throughout your code, the solutions in this article are great.

@Andrzej Gis 2013-08-15 20:20:50

In case you need a Distinct method on multiple properties, you can check out my PowerfulExtensions library. Currently it's in a very young stage, but already you can use methods like Distinct, Union, Intersect, Except on any number of properties;

This is how you use it:

using PowerfulExtensions.Linq;
...
var distinct = myArray.Distinct(x => x.A, x => x.B);

@Contango 2013-02-06 19:56:37

The following code is functionally equivalent to Jon Skeet's answer.

Tested on .NET 4.5, should work on any earlier version of LINQ.

public static IEnumerable<TSource> DistinctBy<TSource, TKey>(
  this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
  HashSet<TKey> seenKeys = new HashSet<TKey>();
  return source.Where(element => seenKeys.Add(keySelector(element)));
}

Incidentially, check out Jon Skeet's latest version of DistinctBy.cs on Google Code.

@What Would Be Cool 2014-04-22 23:42:44

This gave me a "sequence has no values error", but Skeet's answer produced the correct result.

@Timothy Khouri 2009-03-11 12:21:19

I've written an article that explains how to extend the Distinct function so that you can do as follows:

var people = new List<Person>();

people.Add(new Person(1, "a", "b"));
people.Add(new Person(2, "c", "d"));
people.Add(new Person(1, "a", "b"));

foreach (var person in people.Distinct(p => p.ID))
    // Do stuff with unique list here.

Here's the article: Extending LINQ - Specifying a Property in the Distinct Function

@row1 2010-03-17 10:01:21

Your article has an error, there should be a <T> after Distinct: public static IEnumerable<T> Distinct(this... Also it does not look like it will work (nicely) on more that one property i.e. a combination of first and last names.

@nawfal 2012-11-22 12:08:46

+1, a minor error is not a reason enough for downvote, that just so silly, callled a typo often. And I'm yet to see a generic function that will work for any number of property! I hope the downvoter has downvoted every other answer in this thread as well. But hey what is this second type being object?? I object !

@Tom Lint 2019-04-19 08:56:53

Your link is broken

@Jon Skeet 2009-01-28 21:17:13

EDIT: This is now part of MoreLINQ.

What you need is a "distinct-by" effectively. I don't believe it's part of LINQ as it stands, although it's fairly easy to write:

public static IEnumerable<TSource> DistinctBy<TSource, TKey>
    (this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
    HashSet<TKey> seenKeys = new HashSet<TKey>();
    foreach (TSource element in source)
    {
        if (seenKeys.Add(keySelector(element)))
        {
            yield return element;
        }
    }
}

So to find the distinct values using just the Id property, you could use:

var query = people.DistinctBy(p => p.Id);

And to use multiple properties, you can use anonymous types, which implement equality appropriately:

var query = people.DistinctBy(p => new { p.Id, p.Name });

Untested, but it should work (and it now at least compiles).

It assumes the default comparer for the keys though - if you want to pass in an equality comparer, just pass it on to the HashSet constructor.

@mqp 2009-01-28 21:20:53

This is a good solution, if you assume that when there are multiple non-distinct values (like in his example) you're aiming to return the first one that you see in the enumeration.

@Jon Skeet 2009-01-28 21:23:10

Yes, that's what I was assuming based on the question. If he'd requested Person2 and Person3 it would be harder :)

@Chris 2009-06-03 15:35:35

@Jon: +1 Thanks! I'm always surprised by what you can do with Extension methods, they are like that Static Utility class we all carry around

@nawfal 2012-11-25 16:03:30

Jon, I have a serious question, probably on Linq design principles.. You are intaking an IEnumerable and iterating over it, doesn't that mean its not fitting to use this along with Linq, or in other words doesnt this spoil all the goodness of deferred execution? I would say taking an ICollection as the parameter is better since the caller would know directly that the Linq expression is executed and no magic/side effect take place inside the method. I sometimes feel the idea of mixing lazy execution along with C#'s otherwise imperative style is broken! :(

@nawfal 2012-11-25 16:04:55

Or is it that, just because you have used yield statement, it prevents foreach from executing (the enumerable source) ?

@Jon Skeet 2012-11-25 18:39:21

@nawfal: No, it's exactly the opposite - it's because it's deferred and streaming that it fits in with how LINQ works. LINQ uses deferred execution all over the place. It would be very odd to require that it executed eagerly.

@nawfal 2012-11-25 20:22:54

@JonSkeet Yes you are right, I just tested it. I didn't know that its the yield keyword that's helping "deferred execution" though there's a foreach enclosing it. Am I right if I say had there been no yield statement in your foreach, the foreach would have executed the source IEnumerable?

@nawfal 2012-11-25 20:23:59

But I believe having both lazy and eager together in an environment makes it very easy for programmers to not benefit from advantages of the former. I often see IEnumerables taken as argument and iterated over, and that would be very bad had the enumerable been a left over of some linq query

@Jon Skeet 2012-11-25 20:25:55

@nawfal: It's hard to answer you if you keep adding two comments at a time. Also, comment threads aren't really ideal for this. If you want to know about the behaviour of yield, read the specification, experiment, and then ask a new question afterwards. It's not clear what you mean by a "left over" of some linq query... but anyone using LINQ needs to understand deferred execution. There's no getting around that.

@nawfal 2012-11-25 20:32:32

Ok, I understood the yield part. I'm saying, if I had something like this: countries.Select(p => p).OrderBy(p => p).DistinctBy(p => p) and if your DistinctBy method did not use yield keyword, but a plain foreach, then it would have executed the Select and OrderBy queries right? Many times half baked methods spoil Linq advantage that way. I think I'm clearer now. I will make it a separate question if needed. Thanks for your time :)

@nawfal 2012-11-26 00:03:15

@JonSkeet I made it a separate question here stackoverflow.com/questions/13556837/…

@Contango 2013-02-06 19:46:28

@ashes999 2013-02-19 17:04:04

I didn't DV, but I can see one reason why someone would -- you can't use additional libraries (like MoreLINQ) and need "raw" LINQ only.

@Jon Skeet 2013-02-19 17:07:02

@ashes999: I'm not sure what you mean. The code is present in the answer and in the library - depending on whether you're happy to take on a dependency.

@ashes999 2013-02-19 17:27:36

@JonSkeet I used GroupBy since it's simpler: no extra variables (hashset) to declare. However, I do like the extensibility of being able to pass a comparer there.

@Jon Skeet 2013-02-19 17:29:54

@ashes999: If you're only doing this in a single place, ever, then sure, using GroupBy is simpler. If you need it in more than one place, it's much cleaner (IMO) to encapsulate the intention.

@Casey 2014-07-24 19:26:53

The loop could also be written more briefly as return source.Where(e => seenKeys.Add(keySelector(e))).

@Jon Skeet 2014-07-24 19:34:02

@emodendroket: Only if you made it not an iterator block... at which point if you iterated over it twice, the second time you'd get an empty sequence. Not ideal.

@pfeds 2015-08-07 06:24:29

DistinctBy is now part of Microsoft.Ajax.Utilitiies

@Matthew Whited 2017-01-22 12:35:35

this extension method should use the groupby pattern under the covers. This is just bad as it will only work in memory.

@Jon Skeet 2017-01-22 13:34:42

@MatthewWhited: How do you think GroupBy works? (Hint: codeblog.jonskeet.uk/2011/01/01/…) This approach uses less memory, as it doesn't require all the duplicate elements to be retained.

@Matthew Whited 2017-01-22 15:45:55

I know how group by works. I also know that busing hashset against iqueryable would end up with everything working on the client side. This is not a good example plan and simple.

@Jon Skeet 2017-01-22 17:10:36

@MatthewWhited: Given that there's no mention of IQueryable<T> here, I don't see how it's relevant. I agree that this wouldn't be suitable for EF etc, but within LINQ to Objects I think it's more suitable than GroupBy. The context of the question is always important.

@Marc van Nieuwenhuijzen 2017-11-14 12:16:11

Downvoted because it only works on an IEnumerable.

@Phate01 2018-03-10 12:24:43

The project moved on github, here's the code of DistinctBy: github.com/morelinq/MoreLINQ/blob/master/MoreLinq/DistinctBy‌​.cs

@Vinney Kelly 2018-03-20 14:15:18

Me: "What an elegant solution." [Notices the poster is @JonSkeet and smiles inwardly.]

@Zapnologica 2018-05-08 08:06:20

I tired GroupBy() and my project had a reference to it?

@Jon Skeet 2018-05-08 13:55:51

@Zapnologica: I'm afraid I don't understand your comment. Yes, GroupBy is a standard LINQ method, whereas DistinctBy is part of MoreLINQ.

@Zapnologica 2018-05-10 12:19:35

@JonSkeet sorry, I meant DistinctBy() maybe I installed moreLinq somewhere in the past.

@Jon Skeet 2018-05-10 14:37:25

@Zapnologica: Right - so do you have a question about it?

@TanvirArjel 2019-07-31 06:24:15

@JonSkeet How can I write the same extension method for IQueryable ?

@Jon Skeet 2019-07-31 06:32:54

@TanvirArjel: Well, you could use GroupBy and then take the first element from each group, and hope that it does the right thing in the query translation.

@TanvirArjel 2019-07-31 06:37:03

Some something like as follows? public static IQueryable<TSource> DistinctBy<TSource, TKey> (this IQueryable<TSource> source, Func<TSource, TKey> keySelector) { return source.GroupBy(keySelector).Select(g => g.First()).AsQueryable(); } Will it do the query translation properly?

@Jon Skeet 2019-07-31 06:40:36

@TanvirArjel: No, that won't work because you'd need expression trees rather than delegates. But please ask a new question - it's not suitable as comments on a 10 year old thread.

@TanvirArjel 2019-07-31 06:41:49

Okay! Thank you! You are suggesting this: stackoverflow.com/a/491832/5928070, isn't it?

@Jon Skeet 2019-07-31 06:52:48

@TanvirArjel: Yes, effectively.

@TanvirArjel 2019-07-31 06:56:27

One last question: Can write an extension method on IQueryble following this which will be used on all Queryable types dynamically? Based on your yes or no I shall ask the new question. Thank you.

@Jon Skeet 2019-07-31 06:58:59

@TanvirArjel: Again, this sort of thing really isn't suitable for comment threads. It sounds like you really should ask a new question now, and make sure that it's clear about exactly what you're asking. (I don't even know how I'd answer that.)

@Joel 2015-10-30 18:59:07

Personally I use the following class:

public class LambdaEqualityComparer<TSource, TDest> : 
    IEqualityComparer<TSource>
{
    private Func<TSource, TDest> _selector;

    public LambdaEqualityComparer(Func<TSource, TDest> selector)
    {
        _selector = selector;
    }

    public bool Equals(TSource obj, TSource other)
    {
        return _selector(obj).Equals(_selector(other));
    }

    public int GetHashCode(TSource obj)
    {
        return _selector(obj).GetHashCode();
    }
}

Then, an extension method:

public static IEnumerable<TSource> Distinct<TSource, TCompare>(
    this IEnumerable<TSource> source, Func<TSource, TCompare> selector)
{
    return source.Distinct(new LambdaEqualityComparer<TSource, TCompare>(selector));
}

Finally, the intended usage:

var dates = new List<DateTime>() { /* ... */ }
var distinctYears = dates.Distinct(date => date.Year);

The advantage I found using this approach is the re-usage of LambdaEqualityComparer class for other methods that accept an IEqualityComparer. (Oh, and I leave the yield stuff to the original LINQ implementation...)

@Ivan 2015-01-23 14:54:26

I think it is enough:

list.Select(s => s.MyField).Distinct();

@Festim Cahani 2015-08-12 13:44:56

What if he needs back his full object, not just that particular field?

@donRumatta 2015-09-03 10:45:14

What exactly object of the several objects that have the same property value?

@GWLlosa 2009-01-28 20:49:52

You should be able to override Equals on person to actually do Equals on Person.id. This ought to result in the behavior you're after.

@mqp 2009-01-28 20:47:38

You can do it (albeit not lightning-quickly) like so:

people.Where(p => !people.Any(q => (p != q && p.Id == q.Id)));

That is, "select all people where there isn't another different person in the list with the same ID."

Mind you, in your example, that would just select person 3. I'm not sure how to tell which you want, out of the previous two.

Related Questions

Sponsored Content

22 Answered Questions

[SOLVED] How do you give a C# Auto-Property a default value?

26 Answered Questions

[SOLVED] Why not inherit from List<T>?

10 Answered Questions

[SOLVED] IEnumerable vs List - What to Use? How do they work?

8 Answered Questions

[SOLVED] Can you create a simple 'EqualityComparer<T>' using a lambda expression

  • 2009-04-04 05:21:31
  • Simon_Weaver
  • 20035 View
  • 36 Score
  • 8 Answer
  • Tags:   c# linq distinct

12 Answered Questions

[SOLVED] How to use LINQ to select object with minimum or maximum property value

  • 2009-05-27 05:31:25
  • slolife
  • 229474 View
  • 421 Score
  • 12 Answer
  • Tags:   c# .net linq

18 Answered Questions

[SOLVED] Distinct() with lambda?

9 Answered Questions

[SOLVED] Learning about LINQ

1 Answered Questions

Automapper Mapping List<T> to class containing T

  • 2016-03-19 04:52:56
  • pawan nepal
  • 187 View
  • 0 Score
  • 1 Answer
  • Tags:   c# linq automapper

1 Answered Questions

LINQ's Distinct() on a particular property within a List

  • 2016-11-30 17:45:59
  • SpittingLlama
  • 439 View
  • -1 Score
  • 1 Answer
  • Tags:   c# linq

7 Answered Questions

[SOLVED] How to get distinct instance from a list by Lambda or LINQ

Sponsored Content