.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Imran Ghani
Sohaib Khalid

Home >> Code Snippets >> LINQ >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

LINQ sample example

Posted By:nishithraj       Posted Date: November 27, 2009    Points: 10    Category: LINQ    URL: http://www.dotnetspark.com  

LINQ (Language Integrated Query) is now available with the .NET framework 3.5. Microsoft focused on LINQ to reduction codes. Through LINQ we can avoid manual checkings. It'll act simillar to the database query.

Namespace of LINQ is System.Linq;

A sample code for LINQ.

class app {
static void Main() {
string[] names = { "DotNetSpark", "Google", "Microsoft",
"Yahoo", "TCS", "Infosys"};
// Conditional checking through LINQ
IEnumerable expr = from s in names
where s.Length == 5
orderby s
select s.ToUpper();
//looping through result set expr
foreach (string item in expr)
Console.WriteLine(item); }

from p in persons join w in workers
on new { p.FirstName, p.LastName } equals new
{ w.FirstName, w.LastName }
select p;
Join o in orders on p.ProductID equals


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend