Some useful Clauses and Methods of LINQ, Part #8


LINQ supports the following clauses that you can use in a query:

1. from—Enables you to specify the data source and a variable for iterating over the

data source (a range variable).

2.where—Enables you to filter the results of a query.

3.select—Enables you to specify the items included in the results of the query.

4.group—Enables you to group related values by a common key.

5.into—Enables you to store the results of a group or join into a temporary variable.

6.orderby—Enables you to order query results in ascending or descending order.

7.join—Enables you to join two data sources using a common key.

8.let—Enables you to create a temporary variable to represent subquery results.

List of some of the more interesting and useful methods  in LINQ:

. 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 from a sequence.

. Distinct()—Returns distinct items from a sequence.

. Max()—Returns the maximum value from a sequence.

. Min()—Returns the minimum value from a sequence.

. Select()—Returns certain items or properties 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.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.