Questions tagged [onion-architecture]

The *Onion Architecture* is a software architecture proposed by Jeffrey Palermo. It is similar to the *Hexagonal Architecture* (Ports and Adapters) proposed by Alistair Cockburn.

Jeffrey Palermo proposed the Onion Arcitecture. It is similar to Alistair Cockburn's Hexagonal Architecture or Ports and Adapters.

The fundamental motivation of the approach is to avoid layer-to-layer dependencies usually associated with the N-tier architecture approach. This is achieved by placing all infrastructure, including databases, outside the problem domain.

According to Jeffrey Palermo:

The overall philosophy of the Onion Architecture is to keep your business logic and model in the middle (Core) of your application and push your dependencies as far outward as possible.

The problem domain is then completely independent of the required infrastructure (testing, databases, security, etc.). For example, this means that testing database accesses can be done thoroughly without a real database.

291 questions
0
votes
1 answer

Referencing DbContext in StartUp.cs is messing up my architecture in .NET Core app

I am trying to come up with a project structure that will flow properly, but keep running into road blocks. Especially one where I can't figure out where DbContext for EF should go. I don't want my API referencing my Data layer. The only thing I can…
Blake Rivell
  • 13,105
  • 31
  • 115
  • 231
0
votes
1 answer

Login process within Onion Architecture

I want to implement a login process within the Onion Architecture. I can't get my head around how to go about it correctly. Below is my Repository class that will talk to the database. How would I go about checking that an email had not already been…
deco
  • 137
  • 2
  • 11
0
votes
1 answer

What are the references in an onion architecture supposed to look like

I've followed the msdn document on the onion architecture in .net core here, but it seems you can't really have the UI only know about the service layer, without duplicating code. On the last part of the article (The UI), the startup file is…
ddeamaral
  • 1,403
  • 2
  • 28
  • 43
0
votes
2 answers

Asp.net core separation of concern using service layer

I'm having a problem on what is the best approach to design my service layer and use them in my controller. Here is my concern. Currently I'm using this to delete categories [HttpPost] [ValidateAntiForgeryToken] public IActionResult…
0
votes
2 answers

How to check Business logic in Onion Architecture Domain Layer?

I've been working on Website Development and recently started creating an eCommerce project with MVC. I decided to develop it with onion architecture. As I understand my logic divided in 2 different areas: Application logic and Business Logic. As…
0
votes
0 answers

Mapping domain entities into PetaPoco models

I'm using Onion Architecture and PetaPoco micro-orm at my infrastructure layer. How can I map a domain entity from core layer to a petapoco object to access the data via petapoco?
0
votes
0 answers

Onion Architecture Unit Of Work Transaction Not getting Connection String

I am using Onion Architecture with Autofac. In my Dependency Injection Code, I am using: [assembly: WebActivatorEx.PostApplicationStartMethod(typeof(IocConfig), "RegisterDependencies")] namespace AppMVC.Infrastructure.Bootstrapper { public class…
Usman Khalid
  • 3,032
  • 9
  • 41
  • 66
0
votes
1 answer

Onion Framework: Should UI/Controllers have directly access to repository

In Onion framework, outer layer can access all the inner layers. If I go by this, my outer layer (which is UI layer/Controller in MVC) can directly access application/business services and repositories as well. Now, my controller can create a domain…
Pragmatic
  • 3,093
  • 4
  • 33
  • 62
0
votes
1 answer

Onion architecture with IoC on the client

My application uses Domain driven Onion architecture. It has the exact same layers as this. However, I am a bit confused when I am setting up my IoC dependencies in my mvc app in my client layer. Should I be calling things like my repository…
0
votes
1 answer

In an onion architecture can layers access other layers more then one layer of separation down?

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…
chuckd
  • 13,460
  • 29
  • 152
  • 331
0
votes
1 answer

Autofac not working after update

I have updated Autofac.Mvc from version 3.2.1 to 3.3.0, i also updated all other packages including EF, MVC, WebActivatorEx etc and after update it is giving error on my controller no parameterless constructor defined for this object I put a…
0
votes
1 answer

Process list of object by type

I have a requirement to create a Sync method. 1) On input it takes SyncRequest object. class SyncRequest{ public List Objects{get;set;} } class SyncObj{ public Type Type{get;set;} public object Object{get;set;} } 2) Based on…
0
votes
2 answers

ASP.NET MVC ViewHelpers and Dependency Injection

I'd like to create a ViewHelper to localize my ASP.NET MVC application. Something like this: public class Translator { private readonly ITranslationRepository _repo; public Translator(ITranslationRepository repo) { _repo = repo; …
0
votes
0 answers

Loose coupling when using auto generated domain model from external source

I've run into a rather annoying issue when dealing with auto generated classes that's part of the domain model. For example I'm consuming an OData endpoint which has entities that's part of my core domain model. I'm using the OData v4 Client Code…
Snæbjørn
  • 10,322
  • 14
  • 65
  • 124
0
votes
1 answer

With an onion architecture should all lower layer objects be used through an interface?

I'm somewhat new to the onion architecture. I created a service layer that calls repositories in the DAL by manually passing them into the constructor. But now looking at my method I'm using an object from the core domain and I'm wondering if I…
chuckd
  • 13,460
  • 29
  • 152
  • 331