New Posts New Posts RSS Feed: String Comparisons
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

String Comparisons

 Post Reply Post Reply
Author
murray.bryant View Drop Down
Groupie
Groupie


Joined: 11-Jan-2012
Location: Australia
Posts: 44
Post Options Post Options   Quote murray.bryant Quote  Post ReplyReply Direct Link To This Post Topic: String Comparisons
    Posted: 12-Apr-2013 at 12:13am
Hi 

I am banging my head against the wall with a problem.

It is to do with a string comparison not matching the string in an EntityQuery.

I am using the following code

 PredicateDescription pd = PredicateBuilder.Make(
                entityType, lookUpField, FilterOperator.IsEqualTo, lookUpValue);
            query = EntityQuery.Create(entityType, Context).Where(pd);
            pd.IgnoreCase = true;
            retEntity = (Entity) query.FirstOrNullEntity();


My problem is occuring when the lookupValue   is   'Sy '   as in Sy with a space following. trying to match the same in the database

This code does not find it. 

However if I change the value and remove the space following it does find it. Even though in the database the data it is looking up does contain a space.

I am at a loss as to why this is happening I was hoping someone here would know.

thanks

Murray
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 12-Apr-2013 at 6:34am
Have you tried looking at the DebugLog or using SQL Profiler to look at the generated SQL? My guess is it's trimming off the space before it queries it.

Edit:

I've just tested some queries using LinqPad (http://drc.ideablade.com/devforce-2012/bin/view/Documentation/linqpad-driver)
and I'm not able to reproduce it. Have you tried doing a simple query like the below to see if this even works?

 manager.EntityType.Where(e => e.Field == "Sy ");


Edited by smi-mark - 12-Apr-2013 at 6:39am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down