CleanArchitecture | Clean Architecture Solution Template | Architecture library
kandi X-RAY | CleanArchitecture Summary
kandi X-RAY | CleanArchitecture Summary
Clean Architecture Solution Template: A starting point for Clean Architecture with ASP.NET Core
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of CleanArchitecture
CleanArchitecture Key Features
CleanArchitecture Examples and Code Snippets
Community Discussions
Trending Discussions on CleanArchitecture
QUESTION
I am trying to implement an ASP.NET Core MVC web app similar to Jason Taylor's CleanArchitecture design. In the WebUi "layer" I try to implement an abstraction of an IIdentityService
in which I want to access the ClaimsPrincipal associated with the current HttpRequest
.
After some digging through the source code on github, I found that the Controller.User
property stems from ControllerBase.HttpContext? which is derived from ControllerContext which in turn is derived from ActionContext in which the HttpContext
property is defined as
ANSWER
Answered 2022-Feb-21 at 07:21After being hinted in the right direction by @JHBonarius in the comments, I found a documented case in the official documentation
Use HttpContext from custom componentsFor other framework and custom components that require access to HttpContext, the recommended approach is to register a dependency using the built-in Dependency Injection (DI) container. The DI container supplies the IHttpContextAccessor to any classes that declare it as a dependency in their constructors:
QUESTION
In the method GetNotificationCorrespondingToDomainEvent
in
https://github.com/jasontaylordev/CleanArchitecture/blob/main/src/Infrastructure/Services/DomainEventService.cs, it has the following method,
ANSWER
Answered 2022-Feb-12 at 18:50The difference is that
QUESTION
I have a project created using the clean architecture template.
If I want a domain event be raised when a new project is created, where do I add that?
If I have to raise an event whenever a new item be added to a project, I can accomplish that in the Project entity as shown here.
Similarly for MarkCompletion of a ToDoItem as done here.
But its not clear where do I put the code to raise an event when a new Project is created?
One option is doing something like the following in Create End Point here.
...ANSWER
Answered 2022-Jan-30 at 07:20When you need to raise a domain event on project creation I would create a factory method that publishes the event.
You can use a static method or implement a factory object.
QUESTION
For references: https://github.com/ardalis/CleanArchitecture
The BaseEntity model contains a List
. This list is being ignored in when doing EF Migrations.
ANSWER
Answered 2021-Dec-01 at 01:44It's a field, not a property, so it's ignored. EF only maps properties. Yes, since it's a field, it should probably be named _events
instead of Events
.
QUESTION
I am working on a .NET 5 targeted ASP.NET API where I need to access three different SQL databases.
I am using AutoFac as my DI (disclaimer: I am new to AutoFac and have only used the ASP.NET Core build in DI in the past).
I am also using the CleanArchitecture framework from Steve Smith (https://github.com/ardalis/CleanArchitecture)
I am using generic repositories, one for each DbContext (representing the 3 different databases).
I have the following code in my startup project's Startup.cs --> ConfigureContainer method;
...ANSWER
Answered 2021-Sep-16 at 17:10Autofac will give you the most recently registered instance type, which is why you're getting the last one. You can actually request (via DI) an IEnumerable>
in your endpoint class if you want, and Autofac should give you all of the registered instances for that type. That might help you in debugging, or if you want to use some strategy in the endpoint to select which one is the appropriate instance for a given request.
QUESTION
Unhandled exception rendering component:
Cannot provide a value for property
_accountService
on typeInventory_Management.Client.Pages.Authentication.Login
. There are no registered service of typeInventory_Management.Shared.Services.AccountService
.
AccountService.cs
...ANSWER
Answered 2021-Aug-17 at 14:37You need to register your concrete class in Startup class's ConfigureServices method. Try the following.
QUESTION
I using CleanArchitecture solution. I have Data layer where ApplicationDbContext and UnitOfWork are located :
...ANSWER
Answered 2021-Jun-13 at 12:31finally, I found my answers in this article https://snede.net/you-dont-need-a-idesigntimedbcontextfactory/
Create ApplicationDbContextFactory in Portal.Data project:
QUESTION
I am having trouble wiring up identity into Blazor server with ASP.NET Core identity. Specifically getting the correct logged in state in Blazor pages (while I am getting them from the Blazor pages).
I think it's related to some of the startup being initialized in another project - but not sure how to debug it or what the solution is to be able to get the logged in state correctly.
Reproduction steps and link to GH repo below as a POC.
Background
I'm porting over the clean-code project by JasonTaylor from Angular / ASP.NET Core to a Blazor server project with ASP.NET Core Identity.
Issue
The application runs up and I can browse the pages when I register I can see logged-in state in the identity-based default pages but in the Blazor pages that use the AuthorizeView
(e.g. LoginDisplay.razor
) it's not aware of being authorized.
Startup in the Blazor project:
...ANSWER
Answered 2021-Jun-10 at 08:10This was an issue with mixing IdentityServer and ASP.net identity.
By removing Microsoft.AspNetCore.ApiAuthorization.IdentityServer
and the use of base class from ApiAuthorizationDbContext
back to IdentityDbContext
resolved this.
QUESTION
What is the best way to call a SQL function / stored procedure when converting code to use the repository pattern? Specifically, I am interested in read/query capabilities.
Options
- Add an
ExecuteSqlQuery
toIRepository
- Add a new repository interface specific to the context (i.e.
ILocationRepository
) and add resource specific methods - Add a special "repository" for all the random stored procedures until they are all converted
- Don't. Just convert the stored procedures to code and place the logic in the service layer
Option #4 does seem to be the best long term solution, but it's also going to take a lot more time and I was hoping to push this until a future phase.
Which option (above or otherwise) would be "best"?
NOTE: my architecture is based on ardalis/CleanArchitecture using ardalis/Specification, though I'm open to all suggestions.
...ANSWER
Answered 2021-May-02 at 16:21Don't treat STORED PROCEDURES as 2nd order citizens. In general, avoid using them because they very often take away your domain code and hide it inside database, but sometimes due to performance reasons, they are your only choice. In this case, you should use option 2 and treat them same as some simple database fetch.
Option 1 is really bad because you will soon have tons of SQL in places you don't want (Application Service) and it will prevent portability to another storage media.
Option 3 is unnecessary, stored procedures are no worse than simple Entity Framework Core database access requests.
Option 4 is the reason why you cannot always avoid stored procedures. Sometimes trying to query stuff in application service/repositories will create very big performance issues. That's when, and only when, you should step in with stored procedures.
QUESTION
I'm getting this error:
Database operation expected to affect 1 row(s) but actually affected 0 row(s)
when adding a new element to the entity's collection.
Base classes in Domain
project:
ANSWER
Answered 2021-Apr-19 at 16:36The problem was that by generating my Id's manually, the new entity got the Modified
state, instead of Added
state. The fix was using the Fluent API's .ValueGeneratedNever()
method with the modelBuilder
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install CleanArchitecture
Install using dotnet new (preferred - see below)
Install the Visual Studio Template and use it within Visual Studio
Download this Repository
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page