C
C#Bailey

✅ Theoretical question. MediatR and DTO and onion structure

Hello, THe following is just theoretical and I do not need any code In the programming world, transferring the received object from the api to other parts of the programm for processing is seen as bad practise. Keeping this in mind, then we should map the received data (could use automapper). However if I use the onion structure in combination with Mediatr, there is a mapping done automaticly. The reason why I think this is because MediatR (if I'm correct) uses reflection and generic types. This means that there already is a mapping (indirect). Now I think about using this structure without the mappings. ps. If I would use n-tier structure the mapping would go to the same properties in the object only from the contract to the dto. My question what are you're thoughts on this.
J
Jimmacle13d ago
mediatr does not do mapping
E
exe13d ago
There is no mapping in MediatR. It's just pipelining requests to handlers, or whatever terminology you want to call it. It covers CQRS which I think is what you're referring to here. As far as the mapping goes, I tend to steer away from AutoMapper as it's putting a lot of trust in something which is convention based. That's just my opinion though. As long as your API doesn't know about your domain, and your mediatr just sits between and mediates things, mapping is a different concern. Your CQRS layer is fine to know about your domain objects so you can map in those handlers no problem
J
Jimmacle13d ago
i just map to/from DTOs by hand i wouldn't use any complicated architecture either unless the project really called for it $vsa is plenty for lots of projects
E
exe13d ago
That's what I've been doing for a while. AutoMapper is reflection convention based which is really popular. I just don't like the black box nature of it. I feel more comfortable seeing all my mappings explicitly. Not so familiar with all these new terminologies, I'm guessing it's a bit like clean architecture which I've seen and used to some degree myself. I never really force an architectural pattern to projects, it tends to just come out naturally. My domain is always at the very bottom with no dependencies above. I don't really do all the database adapter stuff bob martin harps on about I'll have support for EF core writing and dapper reads in a separate layer, a layer for services, then the CQRS layer which may or may not even use the services, then the API
J
Jimmacle13d ago
yeah my current project is basically EF models, services, and feature folders
E
exe13d ago
yeah sounds like a good start, as it grows, you can create more layers
J
Jimmacle13d ago
yeah, no point in overcomplicating it right out of the gate
E
exe13d ago
bang on! if you're aware of architecture, you'll notice and adapt it over time
B
Bailey13d ago
thanks for youre thoughts.
Want results from more Discord servers?
Add your server
More Posts
Stack overflow exception when closing one formCan't seem to find the issue.. I have a startscreen, and when any key is pressed on startscreen it tAdvice / Guidance on VM application services (Windows Server 2016)Has anyone every come across a virtual machine (3 virtual 2.6Ghz processors, 12GB Ram) where a singlCan anyone help me with the odd prime numbers program?Facing difficulty in college assignment.IndexOutOfRange Leetcode helpHey, having an issue with my leetcode problem. I know that its supposed to be a bitwise XOR operatiovisual studio .net core ironPDFi have problem with export to pdf files. It's works perfectly( create a files and change keyword), bVisual Studio + WPF: "Could Not Load Assembly" despite dlls being available and reference correctThis has been driving me nuts for a day now. It's an intermittent error as had this working fine at how to export datas to json file from mysqlI have datas in mysql I want to move them to a json file. How can I do that?Licensing my programHi, i’m developing a Point Of Sale software and would like to find out possible solutions to manage ✅ Unhandled exception. Cannot print exception string because Exception.ToString() failed.justwhy this error always come in dotnet webapi application version ----- dotnet --version ✅ How to use Dapper with Query ParametersI work a lot with SQL databases such as MySQL, SQLite and PSQL and usually I write my Queries like t✅ transaction in transaction issueI have this error: `The connection is already in a transaction and cannot participate in another trHelp making login function c#Im currently trying to code a login function I have the registration my user is getting saved in thProblems with docker and my app imageI already posted a question that more or less manage to solve but now i have other problem, the thiAttempting to get value from different JSON files with variable keyHello o/ I am attempting to deserilize and obtain the value from a variety of JSON files that contaiHow to display only department fields associated with a selected department in student automationhi, I'm facing a challenge while working on the student automation system. After selecting the deparHelp with DiscordGameSDK in a C# project (no Unity)I am currently trying to develop a plugin for a Unity game. For this I created a C# project, where IMarshal.GetActiveObject("Word.Application") fall in exceptionI'm working on a `.NET Framework` console application, I have added the `Microsoft.Office.Interop.WMigrating to Microsoft.IdentityModel.JsonWebTokens .net6 => .net8Hi, I am migrating a project which uses Duende as identity server + Ocelot gateway from .NET 6 to .NProcess working set is twice as commited managed memoryHi! I have an ASP.NET Core 8 app running on Linux in Docker. It's memory usage is limited by 512M. Resource based authorization with IdentityHello, I have the following setup in my asp.net core project: A `Workspace` model that has a bunch o