What is Linq & linq to sql some sample examples in vs2010

Posted by Niranjan11 under C# on 8/24/2012 | Points: 10 | Views : 1405 | Status : [Member] | Replies : 3
hi all
What is Linq & linq to sql some sample examples in vs2010
please clarify me

thanking you


bye

BestRegards
Niranjan

reagards
niranjan



Responses

Posted by: Maheshvishnu on: 8/31/2012 [Member] Starter | Points: 25

Up
0
Down
Compared to SQL, LINQ is simpler, tidier, and higher-level.

By using Linq we can query data in Collection,XML files,Entity,which is not possible with sql.

advantages of LINQ over SQl :
1.Debugging support:
I can use any .NET debugger to debug the queries. With sprocs, you cannot easily debug the SQL and that experience is largely tied to your database vendor (MS SQL Server provides a query analyzer, but often that isn't enough).
2.Deployment:
it's easier to deploy a single assembly than to deploy a set of stored procedures in sql.

mahesh

Niranjan11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajkatie on: 8/31/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Microsoft provides 101 example of linq in both VB and C#. you can download from below URL

http://msdn.microsoft.com/en-us/vstudio/aa336746.aspx

Rajesh Patel
.Net Trainer(M.C.S.A | MCT)
Brainbench (Asp.Net 4.5 and C# 5.0)

Niranjan11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 8/31/2012 [Member] Starter | Points: 25

Up
0
Down
Hey Niranjan,

Mainly we can say that LINQ is nothing but a process of querying the data from any source, that data source could be any collections of objects,database or XML files. Microsoft mainly divides LINQ into three areas that are-

. LINQ to Object
. LINQ to ADO.Net (1.LINQ to SQL (formerly DLinq) , 2.LINQ to DataSet , 3.LINQ to Entities)
. LINQ to XML (formerly XLinq)

Examples of Linq

LINQ to Object

Grouping the values of List according to there occurences
List<string> myList=new List<string>();

myList.Add("aaa");
myList.Add("bbb");
myList.Add("aaa");
myList.Add("bbb");
myList.Add("ccc");
myList.Add("ddd");
myList.Add("aaa");
myList.Add("ccc");
myList.Add("aaa");
myList.Add("ccc");
var query = from i in myList
group i.Count() by i into l
select new{l.Key,Count=l.Count()};
foreach(var item in query)
{
Console.WriteLine(item);
}






G. S.
.Net Developer

Niranjan11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response