Expression/formula as column mapping (calculated fields)
See original GitHub issueHello,
I know that this is not the design of an entity-table mapping, but is there a way to create some kind of formula or expression mapping? NHibernate has something like this Nhibernate mapping property I would think about somthink like :
[Table("CUSTOMER")]
public partial class Customer
{
[Column("ID"), PrimaryKey, NotNull] public int Id { get; set; }
[Column(), NotNull] public string Name { get; set; }
[Column(), NotNull] public string FirstName { get; set; }
[Column(), Nullable ] public string Company { get; set; }
[Column(), NotNull] public string ZipCode { get; set; }
[Column(), NotNull] public string Town { get; set; }
[Column(Expression="select s.STATUS from CUSTOMER_STATUS s where s.CUSTOMER_ID = {Id}")
public int CustomerStatus{ get; set; }
}
To access the Customer properties, you could write the property as curly brackets, or access it directly with column name :
[Column(Expression="select s.STATUS from CUSTOMER_STATUS where s.CUSTOMER_ID = ID")]
Issue Analytics
- State:
- Created 6 years ago
- Comments:38 (38 by maintainers)
Top Results From Across the Web
How to map a calculated field to JPA entity?
I am trying to find a way to put a calculated field within a JPQL query to map to an entity in Spring...
Read more >How to make 1-1 mapping of column based on results from ...
I am using some sort of calculated field for classifying column 2. But unfortunately a record is being mapped to 2 categories which ......
Read more >Calculated Fields | Visualize and present data
A calculated field is a field that uses existing database fields and applies additional logic — it allows you to create new data...
Read more >Create calculated columns in Power BI Desktop
Learn how to create calculated columns using Data Analysis Expressions (DAX) formulas in Power BI Desktop.
Read more >Common calculated expressions for ArcGIS Field Maps
Calculated expressions in ArcGIS Field Maps streamline all kinds of data collection workflows from storing location as an attribute, to pulling ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Let’s add a flag like IsColumn/IsExpressionColumn/IsWhateverColumn to ExpressionMethod attribute. It will cover this case and will not conflict with the library design.
I see, thanks!!