無為

          無為則可為,無為則至深!

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            190 Posts :: 291 Stories :: 258 Comments :: 0 Trackbacks
          它是Language Integrated Query。
          當我們要對數據庫表進行查詢的時候,我們一定會編寫"select * from sometable where ID = .."的語句。好,那我們現在根據LINQ的語法,完全可以將我們熟悉的SQL中像"select","from","where"等語句在.NET Framework環境中順利使用并且大大提高開發的效率。

          下面我就牛刀小試,做個demo看看。

          1. 先下載LinQ框架?
          ????現在最新版本是2006年5月發布"Orcas CTP", 下載地址(這里 )

          2. 下載安裝待完畢。

          3. 新建一個"LINQ Console Application"項目。

          4. 輸入代碼如下:???

          ?1
          ?2using?System;
          ?3using?System.Collections.Generic;
          ?4using?System.Text;
          ?5using?System.Query;
          ?6using?System.Xml.XLinq;
          ?7using?System.Data.DLinq;
          ?8
          ?9namespace?LINQConsoleApplication1
          10{
          11????class?Program
          12????{
          13????????static?void?Main(string[]?args)
          14????????{
          15????????????string[]?aBunchOfWords?=?{"One","Two",?"Hello",?"World",?
          16
          17"Four",?"Five"}
          ;
          18????????????var?result?=?
          19????????????from?s?in?aBunchOfWords?//?query?the?string?array?
          20????????????where?s.Length?==?5?????//?for?all?words?with?length?=?5
          21????????????select?s;???????????????//?and?return?the?string
          22????????????foreach?(var?s?in?result)?{
          23????????????????Console.WriteLine(s);?//print
          24????????????}

          25????????}

          26????}

          27}

          28
          29


          運行結果如下:
          Hello
          World
          print any key to continue ...



          凡是有該標志的文章,都是該blog博主Caoer(草兒)原創,凡是索引、收藏
          、轉載請注明來處和原文作者。非常感謝。

          posted on 2006-06-10 12:56 草兒 閱讀(364) 評論(0)  編輯  收藏 所屬分類: DotNet
          主站蜘蛛池模板: 上蔡县| 吕梁市| 望都县| 康马县| 奇台县| 宁城县| 稻城县| 门头沟区| 高要市| 绩溪县| 富锦市| 云和县| 来凤县| 泸西县| 万州区| 隆昌县| 揭阳市| 东明县| 芜湖县| 任丘市| 桃园县| 衡东县| 清水河县| 军事| 新兴县| 科技| 招远市| 涞源县| 乳山市| 措美县| 宽城| 六安市| 永福县| 鹤庆县| 平泉县| 隆化县| 东港市| 调兵山市| 富顺县| 冕宁县| 潞城市|