I have a list which consists of the following properties:
public class Category
{
public int RecordId { get; set;}
public string Category { get; set;}
public Data DataObj { get; set;}
}
My list is defined as List<Category>
categories.
The data class holds the following properties:
{
Id: 1,
Name: "Smith",
Input: "7,8",
Output: "Output1",
CreatedBy: "swallac",
CreatedON: "12/01/2018"
},
{
Id: 3,
Name: "Austin",
Input: "9,10",
Output: "Output1",
CreatedBy: "amanda",
CreatedON: "12/03/2018"
},
{
Id: 2,
Name: "Austin",
Input: "9,10",
Output: "Output1",
CreatedBy: "amanda",
CreatedON: "12/03/2018"
}
How can I get the duplicate item in the Data object?
I have tried the following but does not seem to return me the correct results.
var categoriesFiltered = categories.Select(g => g.DataObj);
var duplicateDataa = categoriesFiltered.GroupBy(x => x)
.Where(g => g.Count() > 1)
.Select(y => y.Key);