<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Error when trying to query case insensitive</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : Error when trying to query case insensitive</description>
  <pubDate>Wed, 29 Apr 2026 00:42:13 -700</pubDate>
  <lastBuildDate>Fri, 20 Nov 2009 13:23:32 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=1564</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Error when trying to query case insensitive : Thanks Greg, I think I will dig...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1564&amp;PID=5841#5841</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=550" rel="nofollow">Niels Verkaart</a><br /><strong>Subject:</strong> 1564<br /><strong>Posted:</strong> 20-Nov-2009 at 1:23pm<br /><br />Thanks Greg,<br />I think I will dig some deeper, but I think waiting for EF 4 will be better and pick up from there. In the meantime there is so much more for me to explore in DevForce, SL, Prism, etc<br /><br />Cheers,]]>
   </description>
   <pubDate>Fri, 20 Nov 2009 13:23:32 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1564&amp;PID=5841#5841</guid>
  </item> 
  <item>
   <title>Error when trying to query case insensitive :  The non-support of   StartsWith(System.String,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1564&amp;PID=5840#5840</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=4" rel="nofollow">GregD</a><br /><strong>Subject:</strong> 1564<br /><strong>Posted:</strong> 20-Nov-2009 at 1:06pm<br /><br />The non-support of <br><br>&nbsp; &nbsp; StartsWith(System.String, System.StringComparison)<br><br>is EF's, not ours. A query like<br><br>&nbsp;&nbsp;&nbsp; Manager.Customers.Where(c =&gt; c.CompanyName.StartsWith("A")) <br><br>against the database will of course be case-insensitive.&nbsp; You can force the query to go against the database by adding a call to the With() extension method:<br><br>&nbsp;&nbsp; Manager.Customers.Where(c =&gt; c.CompanyName.StartsWith("A")).With(QueryStrategy.DataSourceOnly)<br><br>But we don't know of a better solution for you (with the current version of EF) for writing a query that would be case-insensitive against both the database and the cache without using something like ToLower().<br><br><i>Additional comments from another developer in our shop:</i><br><br><font color="#003300"><font color="#006600">EF doesn’t support StringComparison on the StartsWith operator, but interestingly does (as stated in the referenced blog post) with the Equals operator.&nbsp; The error reported in the first post was due to a serialization problem since he was probably working in SL.&nbsp; But no matter, EF doesn’t support this, so we can’t either.&nbsp;&nbsp; StartsWith type of queries are translated by EF (or the provider) into bizarre charindex() sql queries, which likely won’t use the desired index anyway (although I don’t know if the poster was more interested in case insensitivity in general or specifically with StartsWith).&nbsp;&nbsp; So yeah, I don’t think there’s a way to optimize this now (although I think there are improvements in EF 4 …).<br></font><br></font><br><span style="font-size:10px"><br /><br />Edited by GregD - 20-Nov-2009 at 1:19pm</span>]]>
   </description>
   <pubDate>Fri, 20 Nov 2009 13:06:16 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1564&amp;PID=5840#5840</guid>
  </item> 
  <item>
   <title>Error when trying to query case insensitive : Thanks for your reply Greg,  Funtionaly...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1564&amp;PID=5839#5839</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=550" rel="nofollow">Niels Verkaart</a><br /><strong>Subject:</strong> 1564<br /><strong>Posted:</strong> 20-Nov-2009 at 1:07am<br /><br />Thanks for your reply Greg,<DIV>&nbsp;</DIV><DIV>Funtionaly this works, but, as far as I know, is not&nbsp;optimized on the SQL backend. With a larger table this would result in very slow responses because the SQL indexes wouldn't be used.</DIV><DIV>&nbsp;</DIV><DIV>My screens have a search view portion, when a user enters a character in a search field, the query would be send right away (although others would maybe use a search button first). This is my preferred way and I use it in my programs for 15 years. This can only work when we use some indexing, and if we avoid constructions that would not make use of it, like ToLower() on the attribute/fieldname. </DIV><DIV>&nbsp;</DIV><DIV>But isn't there a simpler option to make all queries search case insensitive by default? I mean, somewhere in EF there must be some logic that says to SQL to use case sensitive instead, because the SQL database itself is case insensitive (so any direct query on it, is case insensitive). Maybe there is an option to turn that off?</DIV><DIV>&nbsp;</DIV><DIV>When saying that I decided to look for this 'supposed' setting.... I couldn't find one. I stumbled across a small blog:</DIV><DIV><a href="http://justgeeks.blogspot.com/2009/05/making-linq-to-entities-do-case.html" target="_blank"><U>http://justgeeks.blogspot.com/2009/05/making-linq-to-entities-do-case.html</U></A></DIV><DIV>&nbsp;</DIV><DIV>It states that LINQ to Entities could use the StringComparison, but is this then somehow related to something not implemented in DevForce?</DIV><DIV>&nbsp;</DIV><DIV>best regards,</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Fri, 20 Nov 2009 01:07:00 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1564&amp;PID=5839#5839</guid>
  </item> 
  <item>
   <title>Error when trying to query case insensitive : When I do that in a simple console...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1564&amp;PID=5836#5836</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=4" rel="nofollow">GregD</a><br /><strong>Subject:</strong> 1564<br /><strong>Posted:</strong> 19-Nov-2009 at 4:57pm<br /><br />When I do that in a simple console app, the message I get is<br><br>&nbsp; &nbsp; LINQ to Entities does not recognize the method 'Boolean StartsWith(System.String, System.StringComparison)' method, <br>&nbsp;&nbsp;&nbsp; and this method cannot be translated into a store expression.<br><br>Would this work for you?<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var query = _mgr.Customers<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Where(c =&gt; c.CompanyName.ToLower().StartsWith("a"));<br><br>]]>
   </description>
   <pubDate>Thu, 19 Nov 2009 16:57:37 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1564&amp;PID=5836#5836</guid>
  </item> 
  <item>
   <title>Error when trying to query case insensitive : Hi,  I want to query an object...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1564&amp;PID=5833#5833</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=550" rel="nofollow">Niels Verkaart</a><br /><strong>Subject:</strong> 1564<br /><strong>Posted:</strong> 19-Nov-2009 at 3:30am<br /><br />Hi,<br /><br />I want to query an object but ignoring the case in the database (the database is case insensitive, it is the Ideablade Prism example database). But I get an error when using a StringComparer in the Linq query:<br /><br />There was an error while trying to serialize parameter http://ideablade.com/EntityModel:entityQuerySurrogate. The InnerException message was 'Type 'System.StingComparison'with data contract name 'StringComparison:http://schemas.datacontract...'<br /><br />The query I changed was the second one:<br /><br />Queries.Add("Get Customers starting with A",<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Manager.Customers<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Where(c =&gt; c.CompanyName.StartsWith("A",StringComparison.CurrentCultureIgnoreCase)));<br /><br />What am I doing wrong here?<br /><br />thanks.<span style="font-size:10px"><br /><br />Edited by Niels Verkaart - 19-Nov-2009 at 3:31am</span>]]>
   </description>
   <pubDate>Thu, 19 Nov 2009 03:30:31 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1564&amp;PID=5833#5833</guid>
  </item> 
 </channel>
</rss>