New Posts New Posts RSS Feed: Case InSensitive string Query
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Case InSensitive string Query

 Post Reply Post Reply
Author
EisenbergEffect View Drop Down
Newbie
Newbie
Avatar

Joined: 20-Aug-2010
Location: Tallahassee, FL
Posts: 11
Post Options Post Options   Quote EisenbergEffect Quote  Post ReplyReply Direct Link To This Post Topic: Case InSensitive string Query
    Posted: 20-Aug-2010 at 11:05am
I would like to use linq to query for all Persons with a certain Name. However, I would like to do this in a case insensitive way. Currently, I am using Name.Contains(searchText), but that isn't working.

Edited by EisenbergEffect - 02-Sep-2010 at 11:28am
Back to Top
bennage View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Aug-2010
Location: Tallahassee, FL
Posts: 9
Post Options Post Options   Quote bennage Quote  Post ReplyReply Direct Link To This Post Posted: 20-Aug-2010 at 2:37pm
Some additional information about this problem. The db is case insensitive.
I'm catching the generated SQL with EFPRof and when I run it manually I get a row back. Is DevForce possibly filtering the results from the db?
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 20-Aug-2010 at 4:14pm

Our next build will have queries set to the SQL Server defaults (case insensitive, ignore trailing whitespace), and will have options for you to configure the behavior if you need something different.

In the meantime, you can perform the query like this:
entityManager.Employees.Where(emp => emp.FirstName.Equals("Kathy", StringComparison.CurrentCultureIgnoreCase);
 
Back to Top
EisenbergEffect View Drop Down
Newbie
Newbie
Avatar

Joined: 20-Aug-2010
Location: Tallahassee, FL
Posts: 11
Post Options Post Options   Quote EisenbergEffect Quote  Post ReplyReply Direct Link To This Post Posted: 20-Aug-2010 at 4:46pm
That will work in the mean time. Thanks!
Back to Top
EisenbergEffect View Drop Down
Newbie
Newbie
Avatar

Joined: 20-Aug-2010
Location: Tallahassee, FL
Posts: 11
Post Options Post Options   Quote EisenbergEffect Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2010 at 7:00am
Unfortunately, this solution does not work. It causes a serialization error:

There was an error while trying to serialize parameter http://ideablade.com/EntityModel:entityQuerySurrogate. The InnerException message was 'Type 'System.StringComparison' with data contract name 'StringComparison:http://schemas.datacontract.org/2004/07/System' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details.

Getting this simple scenario working is *critical* for our application. I'm using version 6.0.4


Edited by EisenbergEffect - 23-Aug-2010 at 7:12am
Back to Top
WardBell View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Mar-2009
Location: Emeryville, CA,
Posts: 338
Post Options Post Options   Quote WardBell Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2010 at 10:24am
The technique definitely works ... on all of our machines. Something is not quite right in your environment. Following up with you outside the forum. I'll be back with the resolution for our genernal audience.
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2010 at 11:20am
We added support for serialization of the StringComparison type in 6.0.5.  You can work around this now by adding this as a known type; see my reply here - http://www.ideablade.com/forum/forum_posts.asp?TID=2080.
Back to Top
EisenbergEffect View Drop Down
Newbie
Newbie
Avatar

Joined: 20-Aug-2010
Location: Tallahassee, FL
Posts: 11
Post Options Post Options   Quote EisenbergEffect Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2010 at 12:26pm
That did it! Thanks!
Back to Top
WardBell View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Mar-2009
Location: Emeryville, CA,
Posts: 338
Post Options Post Options   Quote WardBell Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2010 at 12:31pm
Hey great. I blamed the customer for not having the proper environment ... like mine ... like DF preview bits that you couldn't possibly have. Sorry about that!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down