<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>LINQ</title><link>http://blog.blueshop.com.tw/hent/category/2177.aspx</link><description>LINQ</description><managingEditor>puma</managingEditor><dc:language>zh-TW</dc:language><generator>.Text Version 0.95.2004.101</generator><item><dc:creator>puma</dc:creator><title>利用字串的StartsWith,EndsWith,Contains,讓LINQ有像sql指令like的功能</title><link>http://blog.blueshop.com.tw/hent/archive/2008/01/26/54174.aspx</link><pubDate>Sat, 26 Jan 2008 00:50:00 GMT</pubDate><guid>http://blog.blueshop.com.tw/hent/archive/2008/01/26/54174.aspx</guid><wfw:comment>http://blog.blueshop.com.tw/hent/comments/54174.aspx</wfw:comment><comments>http://blog.blueshop.com.tw/hent/archive/2008/01/26/54174.aspx#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://blog.blueshop.com.tw/hent/comments/commentRss/54174.aspx</wfw:commentRss><trackback:ping>http://blog.blueshop.com.tw/hent/services/trackbacks/54174.aspx</trackback:ping><description>在小喵的blog裡有一篇文章,有人問到vb.net 和 c# 的LINQ寫法有一點不同&lt;br&gt;&lt;br&gt;&lt;A href="http://blog.blueshop.com.tw/topcat/archive/2007/12/07/53579.aspx"&gt;LINQ to Object初體驗(使用物件取代二維陣列作資料篩選)&lt;/a&gt;&lt;br&gt;&lt;br&gt;小弟去網路找了一下資料...在C#的 like 其實有一個方法可以用&lt;br&gt;&lt;br&gt;SqlMethods.Like的方法&lt;br&gt;&lt;br&gt;在System.Data.Linq.SqlClient命名空間裡
&lt;br&gt;&lt;br&gt;參考網址：&lt;a href="http://209.85.175.104/search?q=cache:lXFfrJURda4J:www.cnblogs.com/126/archive/2007/08/01/839448.html+SQLMETHOD+LINQ&amp;amp;hl=zh-TW&amp;amp;ct=clnk&amp;amp;cd=2&amp;amp;gl=tw"&gt;C#3.0入门系列（十一）-之In, Like操作&lt;/a&gt;&lt;br&gt;&lt;br&gt;小弟做了一個使用string的StartsWith,EndsWith,Contains來達到like的功能&lt;br&gt;&lt;br&gt;asp.net(c#) &lt;br&gt;&lt;br&gt;環境：Visual Studio 2008 , .NET Framework 3.5&lt;br&gt;&lt;br&gt;&lt;textarea name="code" class="c#" cols="50" rows="6"&gt;using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Data.Linq.SqlClient;

public partial class LinqTest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //文字資料庫
        string[] StrDB = { "Puma", "BlueShop", "Microsoft", "Linq","Ling","Luma" };

        //like "Li%"
        IEnumerable&amp;lt;string&amp;gt; StrSelete = from str in StrDB where str.StartsWith("Li") orderby str select str;
        /*
         result:
                 Ling
                 Linq
         */

        //like "%ma"
        //IEnumerable&amp;lt;string&amp;gt; StrSelete = from str in StrDB where str.EndsWith("ma") orderby str select str;
        /*
         result:
                 Luma
                 Puma
         */


        //like "%i%"
        //IEnumerable&amp;lt;string&amp;gt; StrSelete = from str in StrDB where str.Contains("i") orderby str select str;
        /*
         result:
                 Ling
                 Linq
                 Microsoft
         */

        //列出查詢結果
        foreach (string item in StrSelete)
        {
            Response.Write(item + "&amp;lt;br/&amp;gt;");
        }
    }
}
&lt;/textarea&gt;&lt;br&gt;&lt;br&gt;&lt;img src ="http://blog.blueshop.com.tw/hent/aggbug/54174.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>puma</dc:creator><title>利用LINQ做簡單的字串陣列查詢</title><link>http://blog.blueshop.com.tw/hent/archive/2008/01/24/54161.aspx</link><pubDate>Thu, 24 Jan 2008 23:21:00 GMT</pubDate><guid>http://blog.blueshop.com.tw/hent/archive/2008/01/24/54161.aspx</guid><wfw:comment>http://blog.blueshop.com.tw/hent/comments/54161.aspx</wfw:comment><comments>http://blog.blueshop.com.tw/hent/archive/2008/01/24/54161.aspx#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://blog.blueshop.com.tw/hent/comments/commentRss/54161.aspx</wfw:commentRss><trackback:ping>http://blog.blueshop.com.tw/hent/services/trackbacks/54161.aspx</trackback:ping><description>最近因為VS2008正式版出來了...小弟也開始在玩LINQ了....&lt;br&gt;&lt;br&gt;小弟做了一個超級簡單的範例...介紹如何使用LINQ這個新技術&lt;br&gt;&lt;br&gt;環境：Visual Studio 2008 + .NET Framework 3.5&lt;br&gt;&lt;br&gt;asp.net(c#)範例&lt;br&gt;&lt;br&gt;&lt;textarea name="code" class="c#" cols="50" rows="6"&gt;using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

public partial class LinqTest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //文字資料庫
        string[] StrDB = { "Puma", "BlueShop", "Microsoft", "Linq" };

        //找出長度大於5的字串,並且排序
        IEnumerable&amp;lt;string&amp;gt; StrSelete = from str in StrDB where str.Length &amp;gt; 5 orderby str select str;

        //列出查詢結果
        foreach (string item in StrSelete)
        {
            Response.Write(item + "&amp;lt;br/&amp;gt;");
        }
    }
}
&lt;/textarea&gt;&lt;br&gt;

&lt;br&gt;執行結果：&lt;br&gt;BlueShop&lt;br&gt;Microsoft&lt;br&gt;&lt;img src ="http://blog.blueshop.com.tw/hent/aggbug/54161.aspx" width = "1" height = "1" /&gt;</description></item></channel></rss>