LINQ offers a great way to query database model where the whole logical
model of the database is generated in the form of entities
You can also query on collections
Suppose to select all rows from table we use Select * from Emp
In LINQ we car assign the results to a Var type or List
Var results=From n in dc.Employee
select n;
to query two tables, an example we can use is using the Northwind
database. Let's assume we want to join the Customers and Orders tables
together
We would write a query like this to retrieve the OrderID, and OrderDate
from the Order table, and the CustomerID and ContactName from the
Customer table:
class Program
{
static void Main(string[] args)
{
using (DataClasses1DataContext db = new DataClasses1DataContext())
{
var query_results = from d in db.Customers
join o in db.Orders
on d.CustomerID equals o.CustomerID
select new { o.OrderID, o.OrderDate, d.CustomerID, d.ContactName };
}
}
}
You can refer 101 LINQ samples
http:///
Regards