Forum:  LLBLGen Pro Runtime Framework

Thread:  Curious about Excluded Fields

simmotech (User)   Posted on: 08-Sep-2017 08:48:47.
I was just curious about the reason behind fetch queries using "NULL AS [xxx]" for excluded fields.

I guess it was to have a one to one with the entity fields into which the results will go but wouldn't it be just as easy to exclude those fields from the query and match returned results by field name?
Otis (LLBLGen Pro Team)   Posted on: 08-Sep-2017 10:01:41.
It's an optimization trick Regular Smiley We had what you suggest before, I think before 4.2, not sure, but then the resultsets are different if you do or don't exclude fields. That would mean to materialize an entity we needed to read/write each field value individually (as it could be on a different ordinal in the row).

By returning NULL for an excluded field, the resultsets for a query with and without excluded fields is the same, so we can then simply pull the full row from the datareader and store it in the entity in 1 go. This is much faster than reading fields individually Regular Smiley