Tuesday, March 4, 2008

LINQ to Object Discussed

LINQ
LINQ(Language Integrated Query) is a new technology with Dot Net framework 3.5 support Querying Data. That means it support Querying Collection, XML, SQL table, Dataset and other objects.

In this post I will discuss LINQ to Object.

LINQ to Object
The functionality of LINQ to object is accomplished through the use of IEnumerable<T> interface, Sequence and Standard Query Operator.

IEnemerable<T>: IEnemerable<T> is an interface that all the C# 2.0 Generic collection implements. This collection permits the enumeration of collection elements.

Sequence: Sequence is a logical term if you have a variable of type IEnemerable<T> then you can say you have a sequence of T.

Standard Query Operator:

Most of the standard query operator are Extension methods in the System.Linq.Enumerable static class with an IEnemerable<> as there first argument.
Extension Method: An extension method is a static method of a static class that you can call as though it were an instance method of a different class.

public static class StringConversion
{
public static double ToDouble(this String s)
{
return Double.Parse(s);
}
}

Here ToDouble is an extension method. Extension method have this Keyword preceding first parameter.






No comments: