PrefetchPath introduces case sensitivity

Posts   
 
    
johnsmith
User
Posts: 19
Joined: 14-Dec-2004
# Posted on: 22-Jan-2008 01:46:38   

I've just been trying to find a bug I introduced when doing some optimisation work, and I've tracked it down to what seems like a pretty nasty gotcha to watch out for. The issue reduces to the following example:

CompanyEntity company;
company = new CompanyEntity(123);

// IPrefetchPath path = new PrefetchPath((int)EntityType.CompanyEntity);
// path.Add(CompanyEntity.PrefetchPathDepartment).SubPath.Add(DepartmentEntity.PrefetchPathManager);
// company = new CompanyEntity(123, path);

foreach (DepartmentEntity department in company.Department) 
{ 
    Email(department.Manager.EmailAddress);
}

Where Department joins to one Manager on a char based ManagerID.

As is, the code pulls out the department managers, matching in a case-insensitive fashion, but when the three removed lines are included with the intention of adding a content-neutral performance enhancement, the resulting CompanyEntity is changed such that its departments only match managers in a case sensitive way, leaving an object reference error on department.Manager where ManagerId cases do not match.

Cheers, JS.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Jan-2008 10:09:00   

That's normal as prefetchPaths compare the vales in memory and that's always case sensetive, and the other way is filtering on the database which can be set to be case insensitive.

Please check the following thread for more details. http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=4755