Ejemplo n.º 1
0
        public static IEnumerable <Book> GetLinqAndLeapYearBooks()
        {
            IEnumerable <Book> books         = Initializer.GetNewLibrary();
            IEnumerable <Book> requiredBooks = books.Where(book => book.Name.Contains("LINQ") && DateTime.IsLeapYear(book.Year));

            return(requiredBooks);
        }
Ejemplo n.º 2
0
        public static Dictionary <string, int> GetPairsAuthorAndBookCount()
        {
            IEnumerable <Book> books = Initializer.GetNewLibrary();
            var result = books.Select(book => book.Author).GroupBy(
                author => author,
                (key, value) => new
            {
                Author     = key,
                BooksCount = value.Count()
            }
                ).ToDictionary(x => x.Author, x => x.BooksCount);

            return(result);
        }