Blog

Output of following code:

public class Model {
public string book { get; set; }
public string AuthorName { get; set; }
public DateTime DateOfIssue { get; set; }
public bool Status { get; set; }
}

class Program {

static void Main(string[] args) {
var books = new List {
new Model { book = “EF in c#”, DateOfIssue = new DateTime(2020, 10, 12), AuthorName = “Delphine” },
new Model { book = “Advance c#”, DateOfIssue = new DateTime(2019, 01, 14), AuthorName = “Delphine” },
new Model { book = “EF Core 5”, DateOfIssue = new DateTime(2017, 05, 01), AuthorName = “Delphine” },
new Model { book = “Intro to Node.Js”, DateOfIssue = new DateTime(2020, 11, 04), AuthorName = “Lucien” },
new Model { book = “TS & JS”, DateOfIssue = new DateTime(2019, 12, 06), AuthorName = “Lucien” },
new Model { book = “Javascript”, DateOfIssue = new DateTime(2020, 08, 07), AuthorName = “Lucien” }
};

var mybooks = books
.GroupBy(x => x.AuthorName)
.Select(x => x.First())
.ToList();

foreach (var item in mybooks) {
Console.WriteLine(item.AuthorName);
}
}

}