You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I query all the JournalEntryRef's(ie a collection somewhere) I specify that I want the reference column(beside others) and I'd expect that as such it would return the Invoice number for Invoice JournalEntryRef and Payment number for PaymentEntryRef. But currently they are always null.
Is that a bug? If so how can we fix it? Or is that entirely not possible?
Can you try and use methods instead of properties and see if the issue persists? We have done work to support calling derived projectable methods, I'm not sure if this work also translated to properties.
Can you try and use methods instead of properties and see if the issue persists? We have done work to support calling derived projectable methods, I'm not sure if this work also translated to properties.
Tho to be 100% exact Iam accessing it yet from another class(JournalEntries) as Projectable
There is a problem, during the query compilation phase, we do not know what JournalEntryRef is except for that its JournalEntryRef. So the only sensible thing it can do is project JournalEntryRef.GetDisplayName. Only when the query executes can it resolve what JournalEntryRef actually is.
You'll have to come up with something creative in order to bind to the correct implementation during query execution, e.g.
publicstring?Reference=> JournalEntryRef is InvoiceJournalEntryRef ?((InvoiceJournalEntryRef)JournalEntryRef).GetDisplayName(): JournalEntryRef isPaymentJournalEntryRef?((PaymentJournalEntryRef)JournalEntryRef).GetDisplayName(): JournalEntryRef isBankEntryJournalEntryRef?((BankEntryJournalEntryRef)JournalEntryRef).GetDisplayName():null;
Tho to be 100% exact Iam accessing it yet from another class(JournalEntries) as Projectable
There is a problem, during the query compilation phase, we do not know what JournalEntryRef is except for that its JournalEntryRef. So the only sensible thing it can do is project JournalEntryRef.GetDisplayName. Only when the query executes can it resolve what JournalEntryRef actually is.
You'll have to come up with something creative in order to bind to the correct implementation during query execution, e.g.
publicstring?Reference=> JournalEntryRef is InvoiceJournalEntryRef ?((InvoiceJournalEntryRef)JournalEntryRef).GetDisplayName(): JournalEntryRef isPaymentJournalEntryRef?((PaymentJournalEntryRef)JournalEntryRef).GetDisplayName(): JournalEntryRef isBankEntryJournalEntryRef?((BankEntryJournalEntryRef)JournalEntryRef).GetDisplayName():null;
And can't exactly this be generated by Projectables?
Ie: If we know it's virtual the actual implementation will looks thru what inherits this class and generates the ifs?
Ie: If we know it's virtual the actual implementation will looks thru what inherits this class and generates the ifs?
Technically, yes. However that is a big ask. This would need substantial design. Feel free to propose something but at the moment, this would not be supported :)
Ie: If we know it's virtual the actual implementation will looks thru what inherits this class and generates the ifs?
Technically, yes. However that is a big ask. This would need substantial design. Feel free to propose something but at the moment, this would not be supported :)
Would it be enough for this to work to retrieve all the derived types implementations of each method and then add a switch/if else if based on the type?
Then if the method is used in other projections we would need to duplicate and replace the whole expression for each type.
I wish I could help on this, but in my project NeatMapper I'm using Expressions directly, so I only know about projections/expansions/inlining related to them. I know nothing about Roslyn code generation unfortunately :/
Just to add a note: this would require supporting both abstract and virtual classes/members, this might require changing the Projectable attribute implementation.
Abstract class/member (no body required for Projectable)
publicabstractclassBase{[Projectable]publicabstractstringMyProp{get;}}publicclassDerived1:Base{[Projectable]publicoverridestringMyProp=>"MyProp1";}...
public class DerivedN: Base{publicstringMyPropInternal{get;}[Projectable]publicoverridestringMyProp=> MyPropInternal;}
This would generate an expression like this (no default case):
publicclassBase{[Projectable]publicvirtualstringMyProp=>"Default";}publicclassDerived1:Base{[Projectable]publicoverridestringMyProp=>"MyProp1";}...
public class DerivedN: Base{publicstringMyPropInternal{get;}[Projectable]publicoverridestringMyProp=> MyPropInternal;}
This would generate an expression like this (with last default case):
Activity
koenbeuk commentedon May 25, 2023
Can you try and use methods instead of properties and see if the issue persists? We have done work to support calling derived projectable methods, I'm not sure if this work also translated to properties.
Looking forward to hearing back.
honzapatCZ commentedon May 28, 2023
Still the same
Tho to be 100% exact Iam accessing it yet from another class(JournalEntries) as Projectable
EDIT: Here's the SQL when querying for all the Journal Entries, it seems the the if case is getting generated incorrectly.
koenbeuk commentedon Jun 3, 2023
There is a problem, during the query compilation phase, we do not know what JournalEntryRef is except for that its JournalEntryRef. So the only sensible thing it can do is project JournalEntryRef.GetDisplayName. Only when the query executes can it resolve what JournalEntryRef actually is.
You'll have to come up with something creative in order to bind to the correct implementation during query execution, e.g.
honzapatCZ commentedon Jun 3, 2023
And can't exactly this be generated by Projectables?
Ie: If we know it's virtual the actual implementation will looks thru what inherits this class and generates the ifs?
koenbeuk commentedon Jun 4, 2023
Technically, yes. However that is a big ask. This would need substantial design. Feel free to propose something but at the moment, this would not be supported :)
honzapatCZ commentedon Jun 4, 2023
Ok, Ill look into it
Xriuk commentedon May 25, 2026
Would it be enough for this to work to retrieve all the derived types implementations of each method and then add a switch/if else if based on the type?
Then if the method is used in other projections we would need to duplicate and replace the whole expression for each type.
PhenX commentedon May 25, 2026
That may work, yes.
Xriuk commentedon May 25, 2026
I wish I could help on this, but in my project NeatMapper I'm using Expressions directly, so I only know about projections/expansions/inlining related to them. I know nothing about Roslyn code generation unfortunately :/
Xriuk commentedon Jun 4, 2026
Just to add a note: this would require supporting both abstract and virtual classes/members, this might require changing the Projectable attribute implementation.
Abstract class/member (no body required for Projectable)
This would generate an expression like this (no default case):
Virtual member
This would generate an expression like this (with last default case):
Xriuk commentedon Jun 12, 2026
Just to update that I started working on this, will follow with a PR