Comments (3)
@joecarl Thanks for sharing your thoughts. Any contributions are welcome. Feel free to share the PR.
By the way, it looks like to design/implement the $compute feature. For example:
[Computed]
public decimal TotalKg { get => PlasticKg + OthersKg; }
Here's our proposal:
If an unmapped property (Not Found from Edm Model at the client side) is defined and used in the LINQ Expression, we can do:
- If this property has '[Computed]' decorated, and it only contains the getter, we can generate this property into $compute clause. So
ctx.TestEntities.Where(c => c.TotalKg > 10).ToList();
can be translated to:
~/testEntities?$filter=TotalKey gt 10&$compute=PlasticKg add OthersKg as TotalKey
- If this property has nothing decorated, we can translate this property as nested expression as:
~/testEntities?$filter=(PlasticKg add OthersKg) gt 10
Any thoughts?
from odata.net.
@xuzhg Thankyou very much for your answer.
Your proposal seems good to me, I will think about it and will likely submit a pull request. I have a question though: does the $compute
feature bring any advantage over the non computed query?
Also, about the NotMapped
attribute. It might not be necessary for this case.
But imagine the scenario where my model has a property public decimal Cost { get; set; }
and the OData endpoint actually has a field named Cost
but for whatever reason I don't want to use it (e.g.: the api has obsolete prices and i want to calculate it myself later or maybe the matching name are just an unfortunate coincidence). How could I prevent the materializer from setting that prop? Also how could I make sure that an exception will be thrown if I use that prop in a query? (An exception should be thrown since otherwise I would be doing an unintended filtering and the api would silently return wrong results)
from odata.net.
I've been attempting to implement this, but I've encountered a significant obstacle. The getter method's body cannot be translated at runtime because it is a compiled method, unlike Expression
objects whose tree is stored at compile time, allowing access at runtime.
Does anybody know how to face this problem? Any help is appreciated
from odata.net.
Related Issues (20)
- ODataConventionModelBuilder GetEdmModel Memory / Performance Problem HOT 6
- EdmTargetPath does not get parsed correctly if it contains a collection-valued NavigationProperty HOT 1
- ODataLib Client fails to deserialize payload with @odata.context relative URL starting with ../ HOT 3
- OData.Client 8 preview fails to translate navigation query HOT 3
- Feature gap: enable untyped for ODataResourceValue and ODataCollectionValue
- No ways to set instance annotation for top-level collection value HOT 3
- Business Central Cloud "24.1.18927.19282" breaking changes
- OData.Client DataServiceContext BulkUpdate() Always Uses Protocol Version 4.01 HOT 6
- Failure when posting a request with odata-version header equal 4.01
- Bad performance while using OData client vs using HttpClient on Android HOT 9
- Allow ignoring errors, like collection is null from server response HOT 4
- High CPU Odata Usage AddWithResize() HOT 3
- memory occupied and no longer released HOT 3
- OData Client supports nullable generic types for enums
- Batch requests for DataServiceActionQuery, DataServiceActionQuerySingle and DataServiceQuerySingle HOT 1
- Is there a way to update batch itemβs URL?
- OData8: No way to get top level annotation HOT 3
- EDMX validation fails over DTD HOT 3
- Client 8.0.0 - Projection fails for navigation property being null HOT 1
- Using LINQ to perform various query operations on dynamic properties not supported in OData Client
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odata.net.