zondag 16 september 2018

Een ORM kan tegen je gaan werken...

Een Object Relational Mapper is ontzettend handig als je CRUD operations wil uitvoeren op tabellen. Maar ALLES proberen op te lossen met je ORM is verkeerd. Lees in deze post de ellende van iemand die dat probeert. Hij wil de volgende query door LLBLGen laten genereren:

SELECT 
COUNT(DISTINCT(PstFileEntry.OwnerEntryIdOverride)) as [UserCount], 
SUM(Size)/1024/1024 as FileSizeInMB
FROM PstFileUploadProgress a 
INNER JOIN PstFileEntry ON a.PstFileEntryId = PstFileEntry.PstFileEntryId, 
    (SELECT PstFileUploadProgress.PstFileEntryId, max(PstFileUploadProgressDateTime) as max_date 
    FROM PstFileUploadProgress
    GROUP BY PstFileUploadProgress.PstFileEntryId) b
    
WHERE a.PstFileEntryId = b.PstFileEntryId 
AND a.PstFileUploadProgressDateTime = b.max_date
AND a.PstFileUploadProgressStatus = 1

Kansloze actie!
Dit zijn duidelijk handmatige queries. Voer deze query gewoon uit met ADO.NET.
ORM's zijn niet de oplossing voor alle SQL problemen!

Geen opmerkingen:

Een reactie posten