Visual Studio 2010
LINQ (Language-Integrated Query)
Language-Integrated Query (LINQ) is a set of features introduced in Visual Studio 2008 that extends powerful query capabilities to the language syntax of C# and Visual Basic. LINQ introduces standard, easily-learned patterns for querying and updating data, and the technology can be extended to support potentially any kind of data store. Visual Studio includes LINQ provider assemblies that enable the use of LINQ with .NET Framework collections, SQL Server databases, ADO.NET Datasets, and XML documents.
In This Section
Related Sections
See Also
Other Resources
Community Content
Kamal Saxena - UITS INDIA
LINQ to SQL All in one
LINQ to SQL Implement
var joins =
from a in db.Authors
join b in db.Books
on a.AurthorId equals b.AurthorIdRef
select new { a.AurthorName, b.BookName, b.Edition, b.Price };
var joinData =
(from a in db.Authors
join b in db.Books
on a.AurthorId equals b.AurthorIdRef
select new { a.AurthorName, b.BookName, b.Edition, b.Price }).ToList();
var joinTable =
from a in db.Authors
join b in db.Books
on a.AurthorId equals b.AurthorIdRef
where b.BookId == new Guid()
select new { a.AurthorName, b.BookName, b.Edition, b.Price };
var joinWhere =
from a in db.Authors
join b in db.Books
on a.AurthorId equals b.AurthorIdRef
where b.BookId == new Guid() && b.BookName == "Asp.net"
select new { a.AurthorName, b.BookName, b.Edition, b.Price };
var joinorderby =
from a in db.Authors
join b in db.Books
on a.AurthorId equals b.AurthorIdRef
where b.BookId == new Guid()
orderby b.BookName descending
select new { a.AurthorName,b.BookName };
var grupby =
from b in db.Books
group b by b.BookName into bookGroup
where bookGroup.Count() > 0
orderby bookGroup.Key
select bookGroup;
var joins =
from a in db.Authors
join b in db.Books
on a.AurthorId equals b.AurthorIdRef
select new { a.AurthorName, b.BookName, b.Edition, b.Price };
var joinData =
(from a in db.Authors
join b in db.Books
on a.AurthorId equals b.AurthorIdRef
select new { a.AurthorName, b.BookName, b.Edition, b.Price }).ToList();
var joinTable =
from a in db.Authors
join b in db.Books
on a.AurthorId equals b.AurthorIdRef
where b.BookId == new Guid()
select new { a.AurthorName, b.BookName, b.Edition, b.Price };
var joinWhere =
from a in db.Authors
join b in db.Books
on a.AurthorId equals b.AurthorIdRef
where b.BookId == new Guid() && b.BookName == "Asp.net"
select new { a.AurthorName, b.BookName, b.Edition, b.Price };
var joinorderby =
from a in db.Authors
join b in db.Books
on a.AurthorId equals b.AurthorIdRef
where b.BookId == new Guid()
orderby b.BookName descending
select new { a.AurthorName,b.BookName };
var grupby =
from b in db.Books
group b by b.BookName into bookGroup
where bookGroup.Count() > 0
orderby bookGroup.Key
select bookGroup;