<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Using &amp;quot;Like&amp;quot; in LINQ to SQL</title><link>http://weblogs.asp.net/jgaylord/archive/2008/05/21/using-quot-like-quot-in-linq-to-sql.aspx</link><description>I've recently discovered that LINQ and VB can be confusing. I was attempting to pull the top 10 rows of a table where the column started with 'W'. You'd think after I typed that, I'd figure out the solution. That's not the case. Instead, I struggled.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: Using "Like" in LINQ to SQL</title><link>http://weblogs.asp.net/jgaylord/archive/2008/05/21/using-quot-like-quot-in-linq-to-sql.aspx#7240624</link><pubDate>Tue, 27 Oct 2009 15:44:01 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7240624</guid><dc:creator>varito</dc:creator><author>varito</author><description>&lt;p&gt;How would you use 'like' in linq with a join??&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;p&gt;From Table tabEs&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; INNER JOIN tabCad orP on Es.ColumnID = orP.ColunaID&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; INNER JOIN tabCad orF on orF.ColumnH like orP.ColunaH + '%'&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Where....&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7240624" width="1" height="1"&gt;</description></item><item><title>re: Using "Like" in LINQ to SQL</title><link>http://weblogs.asp.net/jgaylord/archive/2008/05/21/using-quot-like-quot-in-linq-to-sql.aspx#7010577</link><pubDate>Mon, 30 Mar 2009 09:46:05 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7010577</guid><dc:creator>ghg</dc:creator><author>ghg</author><description>&lt;p&gt;ddddddddddddddddddd&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7010577" width="1" height="1"&gt;</description></item><item><title>re: Using "Like" in LINQ to SQL</title><link>http://weblogs.asp.net/jgaylord/archive/2008/05/21/using-quot-like-quot-in-linq-to-sql.aspx#6974053</link><pubDate>Wed, 18 Mar 2009 10:04:15 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6974053</guid><dc:creator>pappu reddy</dc:creator><author>pappu reddy</author><description>&lt;p&gt;i have used in my project .it is working&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6974053" width="1" height="1"&gt;</description></item><item><title>re: Using "Like" in LINQ to SQL</title><link>http://weblogs.asp.net/jgaylord/archive/2008/05/21/using-quot-like-quot-in-linq-to-sql.aspx#6771047</link><pubDate>Mon, 08 Dec 2008 07:33:01 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6771047</guid><dc:creator>Vlad</dc:creator><author>Vlad</author><description>&lt;p&gt;What if I need everything where &amp;quot;doctor&amp;quot;&lt;/p&gt;
&lt;p&gt;with LIKE it whould be:&lt;/p&gt;
&lt;p&gt;Dim q = From t In db.Employees Where t.LastName Like &amp;amp; &amp;quot;%&amp;quot; prefixText &amp;amp; &amp;quot;%&amp;quot; Select t.LastName&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6771047" width="1" height="1"&gt;</description></item><item><title>re: Using "Like" in LINQ to SQL</title><link>http://weblogs.asp.net/jgaylord/archive/2008/05/21/using-quot-like-quot-in-linq-to-sql.aspx#6353074</link><pubDate>Thu, 03 Jul 2008 12:00:27 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6353074</guid><dc:creator>Webys</dc:creator><author>Webys</author><description>&lt;p&gt;I have a little problem I&amp;#39;m a beginner in LINQ to SQL and I&amp;#39;ve follow the tutorial from ScottGu&amp;#39;s blog: &lt;a rel="nofollow" target="_new" href="http://weblogs.asp.net/scottgu/archive/2007/07/16/linq-to-sql-part-5-binding-ui-using-the-asp-linqdatasource-control.aspx"&gt;weblogs.asp.net/.../linq-to-sql-part-5-binding-ui-using-the-asp-linqdatasource-control.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;All was ok I use VS 2008 (I&amp;#39;ve converted from VB.NET to C# , I use C#) but when I wish to put the code from App_Code in an sub dir like DAL or BLL (for extensibility of entities like products with partial clases) and generate again the dblm file I&amp;#39;ve receiving en error:&lt;/p&gt;
&lt;p&gt;1. first in my BLL dir from App_Code:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; public partial class Product&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;partial void OnValidate(System.Data.Linq.ChangeAction action)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (action == ChangeAction.Update &amp;amp;&amp;amp; this.Discontinued == true &amp;amp;&amp;amp; this.UnitsOnOrder &amp;gt; 0)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;throw new ArgumentException(&amp;quot;Record level can&amp;#39;t be grather than 0 if Product is Discontinued&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;} &lt;/p&gt;
&lt;p&gt; and I&amp;#39;ve included the namespace : using DAL; &lt;/p&gt;
&lt;p&gt;... but still error message is :No defining declaration found for implementing declaration of partial method &amp;#39;Product.OnValidate(System.Data.Linq.ChangeAction)&amp;#39;&lt;/p&gt;
&lt;p&gt; 2 &amp;nbsp;If i comment all BLL code from my extensibility partial class Product I receive an general error:&lt;/p&gt;
&lt;p&gt;Could not load type &amp;#39;NorthwindDataContext&amp;#39;.&lt;/p&gt;
&lt;p&gt;Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.&lt;/p&gt;
&lt;p&gt;Exception Details: System.Web.HttpException: Could not load type &amp;#39;NorthwindDataContext&amp;#39;.&lt;/p&gt;
&lt;p&gt;Source Error:&lt;/p&gt;
&lt;p&gt;An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. &lt;/p&gt;
&lt;p&gt;Stack Trace:&lt;/p&gt;
&lt;p&gt;[HttpException (0x80004005): Could not load type &amp;#39;NorthwindDataContext&amp;#39;.]&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +565&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.UI.WebControls.LinqDataSourceView.get_ContextType() +68&lt;/p&gt;
&lt;p&gt;[InvalidOperationException: Could not find the type specified in the ContextTypeName property of LinqDataSource &amp;#39;CategoryLinqDS&amp;#39;.]&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.UI.WebControls.LinqDataSourceView.get_ContextType() +193&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.UI.WebControls.LinqDataSourceView.CreateContextAndTable() +458&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.UI.WebControls.LinqDataSourceView.EnsureContextAndTable(Boolean selecting) +39&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.UI.WebControls.LinqDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +421&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +92&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.UI.WebControls.ListControl.PerformSelect() +31&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e) +26&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.UI.Control.PreRenderRecursiveInternal() +86&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.UI.Control.PreRenderRecursiveInternal() +170&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.UI.Control.PreRenderRecursiveInternal() +170&lt;/p&gt;
&lt;p&gt; &amp;nbsp; System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041&lt;/p&gt;
&lt;p&gt;--------------------------------------------------------------------------------&lt;/p&gt;
&lt;p&gt;Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433&lt;/p&gt;
&lt;p&gt;Thanks in advance guys. :)&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6353074" width="1" height="1"&gt;</description></item><item><title>re: Using "Like" in LINQ to SQL</title><link>http://weblogs.asp.net/jgaylord/archive/2008/05/21/using-quot-like-quot-in-linq-to-sql.aspx#6210160</link><pubDate>Thu, 22 May 2008 12:14:26 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6210160</guid><dc:creator>Mel Grubb</dc:creator><author>Mel Grubb</author><description>&lt;p&gt;For those times that you really DO need to do a real &amp;quot;Like&amp;quot;, and you know you're talking to SQL, there's SqlMethods.Like. &amp;nbsp;For example, when a user is free to add wildcards to a search field. &amp;nbsp;You don't know whether to do a StartsWith, EndsWith, or Contains. &amp;nbsp;Here's an example.&lt;/p&gt;
&lt;p&gt;list = list.Where(o =&amp;gt; SqlMethods.Like(o.FirstName, FirstName))&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6210160" width="1" height="1"&gt;</description></item><item><title>re: Using "Like" in LINQ to SQL</title><link>http://weblogs.asp.net/jgaylord/archive/2008/05/21/using-quot-like-quot-in-linq-to-sql.aspx#6208118</link><pubDate>Wed, 21 May 2008 17:36:07 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6208118</guid><dc:creator>sqlguy6212</dc:creator><author>sqlguy6212</author><description>&lt;p&gt;In case you had not found out .Contains is the equivalent to %String%. &amp;nbsp;Like you it took a while to figure these things out.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6208118" width="1" height="1"&gt;</description></item></channel></rss>