I'm currently testing oData as new backend for our apllication to be renewed. The underlying database contains of about 95 tables and is historically grown and may not always have seen the best choices when it get to be extended.
However, imagine the following relationship of entities/tables:
* there is a single football-event (EventEntity)
* this event can have multiple sponsors (SponsorEntity) and at least one of them is the main-sponsor while others are supporting sponsors
* each sponsor can have a premium-package (PremiumAccessEntity) which could be of type Standard, Premium or AccessAllAreas
* the event can also be attributed as special type (EventTypeEntity) which may be something like Championship, Grassroot, Recreational
If I want to know which premium-package any given event has, I have to check if it has a specific (EventType) set or which of the event's main-sponsors premium-package is the highest.
There are now some problems. In the current code this "property" is an Expression-Tree that is applied to build the responded EventPOCO as well as for filtering.
Question is, how this could be achieved with OData and NetCoreWepApi? I would need a custom-filter e.g. EventPremiumAccess eq 'Premium'
and it should also be possible to be selected when the Event-endpoint is queried e.g. $select=EventPremiumAccess
. On the other hand it should not be able to be set via POST or PUT as it is
a read-only and computed property. I already tried partial classes with properties just depending on another property (database-bound) using NotMapped
attribute but the response did not list the property at all.
As this is all proof-of-concept everything can be used. So latest technology, nuget-packages or whatever should not be the problem here as long it's build with C# and VS2019.
question from:
https://stackoverflow.com/questions/65929238/custom-complex-odata-property-to-use-for-filtering-selecting-base-on-expression 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…