LINQ to Objects
LINQ to Objects • LINQ to Objects allows .NET developers to write “queries” over collections of objects. • Traditionally, working with collections of objects meant writing a lot of looping code using for loops or foreach loops to iterate through a list carrying out filtering using if statements, and some action like keeping a running sum of a total property. • LINQ frees you from having to write looping code; it allows you to write queries that filter a list or calculate aggregate functions on elements in a collection as a set.
An example of calculating the aggregate sum of all the elements would look like
If you are used to Select-From-WhereOrderBy, it might take some time to overcome the muscle memory and move to From-Where-OrderBy-Select.
The end-II
“s in” portion of the query that provides a reference to the set of elements contained in the source,
datasource
Endwith method is of string
Is C# still performing static type checking? The answer is yes, it still statically checks types at compile time. What feature or features of C# are allowing all of this? The answer is Microsoft’s Language Integrated Query, otherwise known as LINQ.
The end