- LINQ stands for Language Integrated Query.
- LINQ is an innovation introduced in .NET Framework 3.5 that bridges the gap between objects and data.
- By using LINQ a .NET programmer can write a query without any knowledge of SQL syntax to intact with data source, by using .NET languages such as C#,VB.
- Before LINQ concept, we have to learn different query language for each type of data source like databases,XML documents.
Syntax:
From <Element_name> in <data source>
[clauses]
select Elecment_name;
From and in are key words.
Element_name can be any user defined variable.
In clauses have where, having and orderby clauses.
class Mainclass
{
static void Main()
{
List<int> listid=new List<int>{20,21,22,23,24,25,26};
var studentid = from id in listid
select id;
foreach(int i in studentid)
{
Console.WriteLine(i);
}
}
}
No comments:
Post a Comment