This post isn’t really a blog post as such, I thought as I watch all the LINQ videos and read various websites I would document useful bits of information that I can reference millions of times over the next 2 years few months.
I am going to be adding to this page more and more over the coming weeks too, to save having lots of different
LINQ Clauses you can use in a query
- from - Enables you to specify the data source and a variable for iterating over the data source (a range variable)
- where - Enables you to filter the results of a query
- select - Enables you to specify the items included in the results of the query
- group - Enables you to group related values by a common key
- into – Enables you to store the results of a group or join into a temporary variable
- orderby – Enables you to order query results in ascending or descending order
- join – Enables you to join two data sources using a common key
- let – Enables you to create a temporary variable to represent sub query results
Useful Enumerable methods (Full list)
- Aggregate() – Enables you to apply a function to every item in a sequence
- Average() – Returns the average value of every item in a sequence
- Count() – Returns the count of items in a sequence
- Distinct() – Returns distinct items in a sequence
- Max() – Returns the maximum value from a sequence
- Min() - Returns the minimum value from a sequence
- Select() – Returns a single value from a sequence
- Single() – Returns a single value from a sequence
- Skip() – Enables you to skip a certain number of items in a sequence and return the remaining elements
- Take() – Enables you to return a certain number of elements from a sequence
- Where() – Enables you to filter the elements in a sequence