I have the unfortunate pleasure of hooking into a legacy immutable db that uses a char PK (which stores an int ironically). In one table of this db the PK has 1 trailing space. In another table, the PK has 2 trailing spaces.
I have created manual 1:m relationships, however I notice 1 major problem:
1) Using the code below:
UserCollection uc = new UserCollection();
IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.UserEntity);
prefetchPath.Add(UserEntity.PrefetchPathTimekeep); // <--- THIS LINE
uc.GetMulti(null, prefetchPath);
The <PrefetchPathTimekeep> produces this query:
SELECT tkinit AS Tkinit, tksort AS Tksort, tklast AS Tklast, tkfirst AS Tkfirst, tktitle AS Tktitle
FROM timekeep
WHERE (tkinit IN
(SELECT EmpNoChar
FROM AttorneyReview.dbo.[User]))
That query returns the correct results. However the LLBL code does not load the User.Timekeep entity, presumably because of a PK string mismatch, presumably because of the trailing space (which SQL server ignores when doing the query).
2) If I do NOT do the prefetch, but instead lazy load, it works great, trailing space issues and all. Of course, I can't take the perf hit of lazy loading.
Problem #1 occurs for both tables I need to join across, 1 with a single trailing ' ', and another with 2 trailing ' '.
What do I do so that LLBL will internally match the results during the prefetch?
C# .Net 2, LLBL v2, self-servicing, sql 2005