-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Nhibernate Formula equivalent #23816
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Which database provider? |
I am using Oracle.EntityFrameworkCore provider. |
@Heisenberg74 We do have computed columns support. Is there anything about it that doesn't satisfy your requirements apart from not having a way of configuring it with a data annotation? modelBuilder.Entity<CustomerOrderLine>()
.Property(p => p.Description)
.HasComputedColumnSql("Inventory_Part_Api.Get_Description(part_no)"); |
@AndriySvyryd Thank you for your answer.
Any idea? Thx |
This seems like a duplicate of #10768. |
Correct ! |
But I don't see the right way to achieve my query. |
@Heisenberg74 This is not yet supported by EF Core. Make sure to vote (👍) for #10768 since we use votes to help decide what to work on and #10768 currently has no votes. |
Thank you for your time. Hope one day this feature will come because the ERP on which I work, uses a lot of stored functions. And I prefer not revert to NHibernate... |
Issue
This issue is a Feature request.
We have some project where we use NHibernate as ORM and we started to move to EF core.
With NHibernate we had a Formula extension which were use to map a property to a stored function.
I miss this one very much
Motivation
Make SQL queries with lot of functions call easier and smaller
Example
To generate the following SQL query :
With NHibernate
Model is:
Mapping is:
To query:
var data = _session.Get<CustomerOrderLine>(new CustomerOrderLine() { OrderNo = 1234, LineNo = 1 });
With EF core
Model is:
To query:
Problems
As you can see in the above example, the code to query the data against the DB is much complicated because I have to make a projection in the Select, means that for ONE "property" mapped to a formula, I have to list all other properties in the Select projection.
And sometimes, the formula is in a sub-sub-child entity, means I have to build a Select projection very very long.
Maybe there is a workaround to make a lighter Select projection, any suggestion appreciated ?
Suggestion
Could be awesome to have the same Formula behaviour in EF core.
Property could be available only on SELECT statement.
Having an attribute like:
Conclusion
Thank you to help me on this, making my code better to read 👍
The text was updated successfully, but these errors were encountered: