F9 Group Marketing and Technology Blog

Marketing, Technology, and current news at http://www.f9group.com/

Entries Tagged ‘sequence’

An Extensive Examination of LINQ: Extending LINQ – Adding Query Operators

As discussed in earlier installments of this article series – most notably in An Introduction to LINQ and The Standard Query Operators – one of LINQ’s primary components is its set of standard query operators . A query operator is a method that operates on a sequence of data and performs some task based on that data, are implemented as extension methods on types that implement the IEnumerable<T> interface . Some of the standard query operators that we’ve explored throughout the articles in this series include: Count , Average , First , Skip , Take , Where , and OrderBy , among others. While these standard query operators provide a great detail of functionality, there may be situations where they fall short. The good news is that it’s quite easy to create your own query operators. Underneath the covers query operators are just methods that extend types that implement IEnumerable<T> and iterate over the sequence performing some task, such as computing the total number of items in the sequence, computing the average, filtering the results, or ordering them. This article examines how to extend LINQ’s functionality by creating your own extension methods. Read on to learn more! Read More >

Share and Enjoy:
  • Digg
  • Google
  • del.icio.us
  • Technorati
  • Facebook
  • MySpace
  • TwitThis
  • Blogsvine
  • description
  • E-mail this story to a friend!
  • Ping.fm
  • Print this article!
  • Slashdot
  • Yahoo! Buzz

An Extensive Examination of LINQ: The Standard Query Operators

Query operators are methods that work with a sequence of data and perform some task based on the data. They are created as extension methods on the IEnumerable<T> interface, which is the interface implemented by classes that hold enumerable data. For example, arrays and the classes in the System.Collections and System.Collections.Generic namespaces all implement IEnumerable<T> . In The Ins and Outs of Query Operators we looked at how to create your own query operator that, once created, can be applied to any enumerable object. While it is possible to create your own query operators, the good news is that the .NET Framework already ships with a bevy of useful query operators. These query operators are referred to as the standard query operators and are one of the primary pieces of LINQ. The standard query operators include functionality for aggregating sequences of data, concatenating two sequences, converting sequences from one type to another, and splicing out a particular element from the enumeration. There are also standard query operators for generating new sequences, grouping and joining sequences, ordering the elements in sequences, filtering the data in a sequence, and partitioning the sequence. All together, there are more than 40 standard query operators. This article explores some of the more germane ones, giving examples of the standard query operator in use and examining its underlying source code

Share and Enjoy:
  • Digg
  • Google
  • del.icio.us
  • Technorati
  • Facebook
  • MySpace
  • TwitThis
  • Blogsvine
  • description
  • E-mail this story to a friend!
  • Ping.fm
  • Print this article!
  • Slashdot
  • Yahoo! Buzz