This is an example out of a book using northwind database. What is the => mean ?
Northwind db = new Northwind(@"Data Source=.\SQLEXPRESS;InitialCatalog=Northwind");
var orders = db.Customers
.Where(c => c.Country == "USA" && c.Region == "WA")
.SelectMany(c => c.Orders);
Console.WriteLine(orders.GetType());
why don’t they just write
Where(c.Country == "USA" && c.Regian == "WA")
The part inside the parentheses of the
Where()needs to be a function that takes aCustomerand returns aboolean value (that’sFunc<Customer, bool>in C#’s type system).It’s most common to write that function using C#’s Lambda Expressions.
The
c =>part means “take theCustomerthat’s passed in to you and call itc. Then with that value ofc, compute this conditional. Without thecon the left side of the=>, the compiler would have no way of knowing whatcrefers to.