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



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

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

Hi..

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:
'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,
Asha.mp
Author: Syed Shakeer Hussain          Company URL: http://www.dotnetspark.com           
Posted Date: October 26, 2010     Points: 5   


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
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

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