0

If I have an onion architecture can my top layer (view) access a layer that is two layers down (models) even if there is a serice layer in between? Or is the purpose of the onion architecture that you only have visibility to layers directly below you?

chuckd
  • 13,460
  • 29
  • 152
  • 331

1 Answers1

0

Doing that would break the architecture so I don't think it is a good idea. With onion architecture you reach to the perfect scenario for Dependency Injection and you don't want to have a mess of injected layers in any other layer.

I am just guessing but, under the hood, your problem seem related to Query to show info in the UI. If this is the case, just use a "View Service" Application Layer which doesn't depend on Domain Services nor Domain Model. Just query to persistence and return plain models for the view (not Domain Entities).

jlvaquero
  • 8,571
  • 1
  • 29
  • 45