0

I have this table/entity scenario in my model-first EF project (simplified):

Machine:
  ID (primary key)
  GroupId (string)
  ActiveConfiguration (of type Configuration)

Configuration:
  ID (primary key)
  GroupId (string)
  ValidFrom (date)

Now what I need to achieve is an association such, that Machine.ActiveConfiguration will contain latest configuration of a given GroupId.

Example (data):

Configuration (ID = '1', GroupId = 'A', ValidFrom = '01/01/2017')
Configuration (ID = '2', GroupId = 'B', ValidFrom = '01/01/2017')
Configuration (ID = '3', GroupId = 'A', ValidFrom = '01/01/2018')

When Machine entity is selected at (for example) 6/30/2017 its ActiveConfiguration property should contain Configuration (ID = '1'). When selected at 6/30/2018 it should contain Configuration (ID = '3').

Is this possible somehow?

SmartK8
  • 2,616
  • 1
  • 29
  • 37
  • There is no way to define this sort of association. What you want to do is write a query that does what you want, and wrap it inside your `ActiveConfiguration` property. – sstan Oct 07 '16 at 12:43
  • That's unfortunate, but it was kinda expected. Thanks. – SmartK8 Oct 07 '16 at 13:50

0 Answers0