We need to add 3 .dlls for LINQ implementation.
Basically LINQ address the current database development model in the context of Object Oriented Programming Model.
It can be devided into three areas
1. LINQ to Object
Queries performed against the in-memory data
2.1 LINQ to SQL (formerly DLinq) {Queries performed against the relation database only Microsoft SQL Server Supported}
2.2 LINQ to DataSet {Supports queries by using ADO.NET data sets and data tables}
2.3 LINQ to Entities {Microsoft ORM solution}
3. LINQ to XML (formerly XLinq)
{ Queries performed against the XML source}
Example shows how to query in a string array.. simple and fun.
 | Model code sample |
| //Look in the example "select " returns a IEnumerable<string>
| | 1:
| | 2:
| | 3:using System;
| | 4:using System.Collections.Generic;
| | 5:using System.Linq;
| | 6:
| | 7:namespace Arindam
| | 8:{
| | 9: class Program
| | 10: {
| | 11: static void Main(string[] args)
| | 12: {
| | 13: string[] names = { "Burke", "Connor", "Frank", "Everett", "Albert", "George", "Harris", "David" };
| | 14:
| | 15: IEnumerable<string> query = from s in names where s.Length == 5 orderby s select s.ToUpper();
| | 16:
| | 17: foreach (string item in query)
| | 18: {
| | 19: Console.WriteLine(item);
| | 20: }
| | 21: Console.ReadLine();
| | 22: }
| | 23:
| | 24: }
| | 25:}
| | 26: |
|
 | Bind gridview from linq query |
| void LoadGrid()
| | 1: {
| | 2: string[] cities = { "London", "Amsterdam", "San Francisco", "Las Vegas","Boston", "Raleigh", "Chicago", "Charlestown", "Helsinki", "Nice", "Dublin" };
| | 3:
| | 4: gvLinq.DataSource = from city in cities where city.Length > 4 orderby city select city.ToUpper();
| | 5: gvLinq.DataBind();
| | 6:
| | 7:
| | 8: }
| | 9: |
|