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

Top 5 Contributors of the Month

Home >> Forum >> ADO.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Waht is LINQ?

Posted By: Dhivakaran     Posted Date: October 26, 2010    Points:2   Category :ADO.Net
Please describe about LINQ and give some real time examples

Author: Asha.MP             
Posted Date: October 26, 2010     Points: 5   


LINQ(Language Integrated Query) is the one of the Concept of object oriented programming and this is one of the feature added to the .net. LINQ is used to query the objects like listof models,Array,Datatable.
This is like SQL query here also we will use select, from, where, And, or and aggregate functions. But in dofferent way.

This is an example where i am using LINQ for the datatable:
Dim dt As New DataTable()

'Adding two columns Name and Age
dt.Columns.Add("Name", GetType(String))
dt.Columns.Add("Age", GetType(Integer))

'Adding Details
dt.Rows.Add("Asha", 20)
dt.Rows.Add("Usha", 10)
dt.Rows.Add("Ashok", 30)
dt.Rows.Add("Teju", 40)

'LINQ for datatable
Dim s = From detail In dt.AsEnumerable() Where detail.Field(Of Integer)("Age") > 20 Select detail
Dim dtOfAgeGre20 = s.CopyToDataTable

In the above example i am using LINQ to the datatable.dtOfAgeGre20 will store the data with the age>20.
Here i am using From in the beginning because we need to declare everything before usage in .Net, The conditios we will write in where clause and In is used to define the object to which we apply LINQ.

Thanks and Regards,
Author: Syed Shakeer Hussain             
Posted Date: October 26, 2010     Points: 5   
Author: Adam Parker             
Posted Date: November 27, 2013     Points: 20   

Language-Integrated Query (LINQ) is a set of features introduced in Visual Studio 2008 that extends powerful query capabilities to the language syntax of C# and Visual Basic. LINQ introduces standard, easily-learned patterns for querying and updating data, and the technology can be extended to support potentially any kind of data store. Visual Studio includes LINQ provider assemblies that enable the use of LINQ with .NET Framework collections, SQL Server databases, ADO.NET Datasets, and XML documents.

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

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