- Today I would like to discuss about the Technology LINQ(Language Integrated Query). The unique way of programming for any type of the data source.
Currently LINQ comes with the following flavors.
LINQ to Objects
LINQ to ADO.NET
LINQ to Entities
LINQ to SQL
LINQ to Entity framework
LINQ to XML
Today let me describe about the current way of coding and then we will refactor the code by using LINQ flavor.
Problem statement:
I want to get the names from the array whose name starts with “V”
Current way of coding….
private static void GetNamesWhichStartswithV()
{
string[] Names = new string[] {
"Vinayaka Shenoy",
"Madhava Shenoy",
"Vijethry Shenoy",
"Divya Shenoy",
"Krishna Shenoy",
"Jayalaxmi Shenoy",
"Chandrakala Shenoy",
"Gurudath Kamath"
};
ListNamesWithV = new List ();
for (int i = 0; i < names =" new">NamesWithVLinq = from n in Names
Wheren .StartsWith("V")
select n;
}
How easy and cool stuff right?
So why you guys are waiting for, start using/exploring LINQ…..
Happy LINQ programming…..
Regards,
-Vinayak
Friday, May 29, 2009
A note on LINQ
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment