Page 1 of 1

Computed properties in queries

Posted: Fri 15 Sep 2017 14:38
by Dredding
Good morning;

Is it possible to mark a property in an entity as computed? What i'm attempting to do is compose a query with expression trees and I need to query my DB based on the expression within a property; Preferably by way of writing the final SQL to represent the property (IE: [psudo](Where x & 1) >0)

Re: Computed properties in queries

Posted: Wed 20 Sep 2017 13:26
by Pinturiccio
There is no such possibility.

Re: Computed properties in queries

Posted: Tue 26 Sep 2017 20:34
by Dredding
Fortunately, I created a way to do it.

Re: Computed properties in queries

Posted: Wed 27 Sep 2017 15:33
by Shalex
As a workaround, compute a column value at the database side (e.g.: via a trigger) and set Auto Generated Value=True, Auto-Sync=OnInsert for the corresponding property in the model.

Re: Computed properties in queries

Posted: Mon 02 Oct 2017 19:27
by Dredding
Thank you.

I found a fairly robust way to accomplish the same goal is to inherit from the base entity and using auto-mapper, map individual "Calculated" fields while selecting the inherited DTO.

This accomplishes my goal of having the calculated fields aliased in the query so they can be accessible to down-stream predicates. Additionally, I don't have to change the schema; although I agree that would be the simplest solution.