Aliendreamer

advanced queiring

Jul 16th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. public static  string GetBooksByAgeRestriction(BookShopContext context,string command)
  2.         {
  3.  
  4.            int restriction =(int)(AgeRestriction)Enum.Parse(typeof(AgeRestriction),command.ToLower(),ignoreCase:true);
  5.  
  6.               var bookTitles = context.Books
  7.                 .Where(x =>x.AgeRestriction==(AgeRestriction)restriction)
  8.                 .Select(x=>x.Title)
  9.                 .OrderBy(x=>x).ToArray();
  10.             string output = string.Join(Environment.NewLine, bookTitles);
  11.             return output;
  12.  
  13.         }
Advertisement
Add Comment
Please, Sign In to add comment