question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expression/formula as column mapping (calculated fields)

See original GitHub issue

Hello,

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:closed
  • Created 6 years ago
  • Comments:38 (38 by maintainers)

github_iconTop GitHub Comments

1reaction
igor-tkachevcommented, Mar 8, 2018

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.

0reactions
frankiDotNetcommented, Mar 28, 2018

I see, thanks!!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found