Microsoft provides to approaches for this:-
1:- LINQ to SQL.
2:- LINQ to ENTITIES.
What Is LINQ to SQL?
LINQ to SQL is an object-relational mapping (ORM) framework that allows the direct 1-1 mapping of a Microsoft SQL Server database to .NET classes.LINQ to SQL provides a runtime infrastructure for managing relational data as objects without losing the ability to query.
We can test our linq queries using Linq Pad.
Which we can download from following link:-
http://www.linqpad.net/
There are various version of Linq pad are available. We can choose the version according to the .Net Framework Version.
Here Some Linq Examples are:-(These all are written in C# statement(s).)
1:-
int[] numbers = { 15, 24, 31, 23, 49, 18, 26, 17, 22, 30 };
var lowNums =
from n in numbers
where n < 25
select n;
Console.WriteLine("Numbers < 25:");
foreach (var x in lowNums)
{
Console.WriteLine(x);
}
Result:-
Numbers < 25:
15
24
23
18
17
22
2:- Order by Demo
string[] words = { "Ashish", "Shashank", "Shikhar","Nihil","Arpit" };
var sortedWords =
from w in words
orderby w.Length,w
select w;
Console.WriteLine("The sorted list of words:");
foreach (var w in sortedWords)
{
Console.WriteLine(w);
}
Result:-
Arpit
Nihil
Ashish
Shikhar
Shashank
Well Friends I'll try to write some more good example in future.
Byeee..