LINQ - linq basics - Asked By kiruba .e on 02-Jul-12 11:15 PM

Hi,


I am new to this linq.  I was not working with linq.  Can anybody please give intro to linq and how to integrate with asp.net?


Thanks

Kiruba.e
avula replied to kiruba .e on 03-Jul-12 01:21 AM
Hi..
LINQ Stands for "Language Integrated Query (Microsoft)".

Situation :
1) I want Select details(FirstName,LastName,Address) of all Customers in Customers table.
  Actually what we do? using ADO.NET we need create Connection,Command and CommandReader or CommandAdaptors required..but using linq. you can integrate your query in to your language like C#.

Example 1:-

var result = from c in Customers
             where c.City == Boston"
             orderby c.LastName descending
             select new { c.FirstName, c.LastName, c.Address };

we also called this as "Linq to Sql"..?
using linq our task is so simpler ever.
 
Example 2:-
var result = from c in datacontext.Customers
             where c.City == Boston"
             orderby c.LastName descending
             select new { c.FirstName, c.LastName, c.Address };


1)what is datacontext?? it is a .dbml file where you can drop your all the table with relationships you can access tables it in your business logic.


Some References :-
1)http://www.codeproject.com/Articles/19154/Understanding-LINQ-C
2)http://stackoverflow.com/questions/471502/what-is-linq-and-what-does-it-do

"You only Make perfect when you start practicing on LINQ. ALL THE BEST"
Regards.