Print Page | Close Window

String Comparisons

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2012
Forum Discription: For .NET 4.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=4110
Printed Date: 25-Mar-2025 at 4:19am


Topic: String Comparisons
Posted By: murray.bryant
Subject: String Comparisons
Date 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



Replies:
Posted By: smi-mark
Date 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 ");



Print Page | Close Window