1.

Assume 2 columns named as Product and Category how can be both sorted out based on first by category and then by product name?(a) var sortedProds = _db.Products.Orderby(c => c.Category)(b) var sortedProds = _db.Products.Orderby(c => c.Category) + ThenBy(n => n.Name)(c) var sortedProds = _db.Products.Orderby(c => c.Category) . ThenBy(n => n.Name)(d) all of the mentionedThis question was posed to me by my school principal while I was bunking the class.Question is taken from Fundamental of LINQ in division Delegates, Generics and LINQ of C#

Answer» RIGHT CHOICE is (c) var sortedProds = _db.Products.Orderby(c => c.Category) . ThenBy(N => n.Name)

BEST EXPLANATION: var sortedProds = _db.Products.Orderby(c => c.Category) . ThenBy(n => n.Name).


Discussion

No Comment Found

Related InterviewSolutions