Search code examples
c#entity-frameworkf#navigation-propertiestransitive-closure

Class hierarchy definition VS (automatically) generated navigational properties


What should drive design consideration for the following case ?

Let's say you have Quotes.

A Quote relates to a specific Contract.

I can define my classes in the following way

Contract =
  someproperty  : int

Quote:
  contract : Contract

Yet when i navigate I would like, even if it does not exists in my model, to be able to do

myContract.quotes

Typically, those properties are generated when using the Entity framework or some other ORM.

But the question of separating the definition from the navigation exists in full generality, even when using pure memory only classes.

(I guess one could frame in into generating the transitive closure of the navigation graph, from the subset of links specified at the definition)

My question is : what are the possible practical approach to inherit automatically those navigational properties in FSharp ? I am just a user, and not an framework developper, abnd this is very low level stuff.

[Obviously you can generalize to more complex class hierarchies can be

  • A Quote comes from a broker, is of bid or ask nature, has a level, and is valide for a specific contract.
  • Contract can be for a certain maturity, say 2013, and refer to a specific company.
  • Company has a ticker, etc, etc... ]

Solution

  • Maybe I've misunderstood; but could you not use an extension method to add the ability to navigate this way? You'd still need to call a function to get the quotes for the particular contract, but the helper would exist, which can just call your data provider for a filtered list of quotes for that contact?