無為

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

            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 草兒 閱讀(363) 評論(0)  編輯  收藏 所屬分類: DotNet
          主站蜘蛛池模板: 崇左市| 遂昌县| 惠安县| 吉首市| 鹿邑县| 阜宁县| 得荣县| 胶南市| 政和县| 乐业县| 鄱阳县| 娱乐| 扎赉特旗| 通城县| 墨竹工卡县| 上犹县| 蒲江县| 临颍县| 临泽县| 巴里| 夏河县| 华亭县| 札达县| 淮阳县| 大连市| 威宁| 古浪县| 广宁县| 龙井市| 蓝田县| 蕲春县| 读书| 开封县| 卢龙县| 甘洛县| 边坝县| 福贡县| 鄂伦春自治旗| 景洪市| 博野县| 三明市|