LINQ是什么簡單分析
本文向大家介紹LINQ是什么,可能好多人還不了解LINQ,沒有關(guān)系,看完本文你肯定有不少收獲,希望本文能教會你更多東西。
LINQ是什么
LINQ是Language Integrated Query (語言集成查詢)。當我們要對數(shù)據(jù)庫表進行查詢的時候,我們一定會編寫"select * from sometable where 的語句。好,那我們現(xiàn)在根據(jù)LINQ的語法,完全可以將我們熟悉的SQL中像"select","from","where"等語句在.NET Framework環(huán)境中順利使用并且大大提高開發(fā)的效率。
1. 先下載LinQ框架
現(xiàn)在***版本是2006年5月發(fā)布"Orcas CTP", 下載地址(http://www.microsoft.com/downloads/details.aspx?familyid=1e902c21-340c-4d13-9f04-70eb5e3dceea&displaylang=en)
2. 下載安裝待完畢。
3. 新建一個"LINQ Console Application"項目。
4. 輸入代碼如下:
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Query;
- using System.Xml.XLinq;
- using System.Data.DLinq;
- namespace LINQConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] aBunchOfWords = {"One","Two", "Hello", "World", "Four", "Five"};
- var result = from s in aBunchOfWords
- where s.Length == 5
- select s;
- foreach (var s in result) {
- Console.WriteLine(s);
- }
- }
- }
- }
運行結(jié)果如下:
Hello
World
print any key to continue ...
以上介紹LINQ是什么。
【編輯推薦】