mr.rendero
mr.rendero
CC#
Created by mr.rendero on 2/7/2023 in #help
✅ LINQ get items with priority
Hello, can I get some assistance with the following issue:
public class Item
{
public string Name { get; set; }
public string Identifier { get; set; }
}
public class Item
{
public string Name { get; set; }
public string Identifier { get; set; }
}
So I have a collection of items (List<Item>) and I need some sort of filtering on them. Lets say we have the following items in the collection: Item 1: Name - Retail Identifier - 001 Item 2: Name - Retail Identifier - 111 Item 3: Name - Hospital Identifier - 111 Item 4: Name - Hospital Identifier - 002 As you can see "Item 2" and "Item 3" have the same Identifier. In those cases where "Identifier" is equal for 2 or more items, I need to take only the one with priority which in my case is "Retail". The final collection that I need to get after filtering is the following: Item 1: Name - Retail Identifier - 001 Item 2: Name - Retail Identifier - 111 Item 3: Name - Hospital Identifier - 002 I'm not sure how to do that with LINQ. Any help will be appreciated, thank you 🙂
11 replies