Great series. I love the way he has this internal dialog with Copilot with "YES!" and seems really impressed with it. A bit like a proud dad. I can sometimes hear a smile. Funny :)
@jimhart57972 жыл бұрын
I have a fundamental issue with these mapping libraries. If object mapping is complicated, we run into these weird config statements that are library specific. You will inevitably have to debug some mapping issue that is buried in a library code. In these situations, I would prefer to manually map it. If the mapping is simple, the mapping library doesn't add any real value and I would prefer to manually map it. AutoMapper/Mapster is one of the very vew libraries I do not find a ton of value in. Having said that, this is another outstanding video Amichai. Thank you for this series!!
@amantinband2 жыл бұрын
Thanks, Jim. Mapping libraries aren't for everyone, and it definitely has its cons 🙂
@ppenxhchqlz31132 жыл бұрын
@@amantinband Is there a way to map only not default values? Like.. ignore 0's and nulls? Thats a huge problem isnt it? When an object come with some null values and they replace not null values
@krccmsitp28842 жыл бұрын
There are two sides to everything. When you have some complicated mapping, you should definitely write unit tests for them to be sure the mapping is correct.
@silvertek2 жыл бұрын
Finally! I've been toying around with automapper vs mapster, and this is a great explanation of all that mapster has to offer.
@yufgyug37352 жыл бұрын
I want to thank you for this video series, helped me a lot in understanding stuff related to clean architecture.
@amantinband2 жыл бұрын
Great to hear!
@DemoBytom2 жыл бұрын
Mapping through Mapster/Automapper might be quite volatile. On the early stages of the project we can make sure that if a model needs special mapping, the profile will be added. But after few years, when one model changes it might be very easy to omit/forget to update/provide new mapping profile. This tutorial could really use a glimpse into testing mapping, either through unit tests or integration (?) tests and how to prevent mapping exceptions being discovered at runtime. Especially it could use some good techinques/best practices how to maintain those profiles as the project grows, team members come and go, scopes change etc.
@amantinband2 жыл бұрын
💯. The main issue with mappers (other than the initial learning curve) is runtime exceptions. I edited out the part where I talk about unit tests, but perhaps I should have at least mentioned it in the final version. Unit tests are a must, whether the objects are manually mapped or mapped via some mapper.
@amantinband2 жыл бұрын
We will have an entire section about testing as part of this series. This will include of course examples for testing the various mappings
@mithrilman34212 жыл бұрын
I was going to say the same, Unit Test is very important, but I see the concern is already addressed and planned on the way
@kmcdo2 жыл бұрын
The drought is over, so excited to watch this one!
@bennyasaraf7805 Жыл бұрын
bro, you killed me at 21:22 lol great walkthru !!! -- thanks
@neutronstar4822 жыл бұрын
I love Mapster much more than any other mapper. Excelent video as allways.
@brunoweb42 жыл бұрын
Mappings sometimes is really painfull... Thanks for the tips! I'm working in a project and trying to implement validations in the most cleaner way... I hope you talk about it really soon :D
@sushilb79942 жыл бұрын
Yes, we need validation video
@amantinband2 жыл бұрын
Yes, there is a lot to talk about 🤙🏼
@karolniedziela36582 жыл бұрын
I am really grateful for this series. Being used to using Automapper, but i will play around with Mapster. Have to catch with up latest video, and waiting for more.
@NaveenKumar-hd7mp2 жыл бұрын
Eagerly waiting for the Episode. Finally 😎
@ArielErlijman2 жыл бұрын
Done! awesome as usual. Waiting for part 8 already!!
@loko-muklisfatoni16652 жыл бұрын
Finally what I've been waiting for
@joaoricardoviccino73112 жыл бұрын
Great, Thanks for the video, I'm loving this knowledge.
@LouisWaweru2 жыл бұрын
Thank you for making these.
@SibTiger332 жыл бұрын
I've been using mapster for a while (converted from automapper) it really is excellent. Fantastic video 👍🎉🎊
@ugursesen76292 жыл бұрын
I'm looking forward to your videos, great tutorial
@HaoNguyen-km9xj2 жыл бұрын
Waiting for the next part! Will you make videos about the testing unit test, integration test???
@amantinband2 жыл бұрын
Yup 👍🏼
@tobiashoft35052 жыл бұрын
The tool you use for the project overview screen, what is it called?
@meetingattender81322 жыл бұрын
Amazing as always thanks much!!! Keep them coming please.
@opachshwee55892 жыл бұрын
Hey man great videos. This series is honestly the best I've seen so far. Any chance you can do some video(s) on proper logging middleware implementation and/or an audit trail with point-in-time rollback capabilities?
@amantinband2 жыл бұрын
Awesome to hear, thanks! I'll definitely touch on logging in future videos
@diego_samano2 жыл бұрын
Awesome videos. Keep going this is a fantastic channel.
@richardhaughton96332 жыл бұрын
Do you recommend injecting the IMapper interface in our mediatr Handlers instead of using the adapt() variant? Is it for testing purposes?
@sushilb79942 жыл бұрын
Very nicely explained. Thank you for yet another useful video.. can you please cover validation in the next video, please?
@amantinband2 жыл бұрын
That's the plan
@canishelix67402 жыл бұрын
Liking the content, when do we get around to DB/Backend storage with this series? Looking forward to Part 8.
@amantinband2 жыл бұрын
Don't worry we'll have multiple videos about EF core after we talk some DDD🙂
@canishelix67402 жыл бұрын
@@amantinband Excellent. Following along with Part 8 now, albeit my own schema and adapting as we go. A more hands-on approach to learning by applying to a project immediately :)
@afsanehhazeghi88902 жыл бұрын
Another informative video, thanks many sir
@ryoman762 жыл бұрын
Great! tnk for this series!
@pilotboba2 жыл бұрын
I think Mapster also includes C# code generators so the mappings don't need to use reflection. Also, you may consider using code generation to do your Injection rather than assembly scanning as well. Maybe consider an installment on code generation.
@fasons22 жыл бұрын
Thank you for your work, it's awesome! I'm curious about mapping in application and infrastructure layers. Shouldn't we use DTOs in application layer to map them to entities in repository? Or is it just redundant work?
@amantinband2 жыл бұрын
The repositories work with domain models. You can, of course, have a mapping layer from domain models to DTOs in your persistence logic. I think it's redundant when using EF Core since we can configure the mapping between the domain models and the actual storage, but we'll talk all about this in future videos 🙂
@Seyanhyriu2 жыл бұрын
Please, I really need some help! Already lost two days with this issue: I got an inputmodel "OrderRequest" with two attributes: string itemCode, List orders. I'm trying to map it to a list of Order entities and get the same itemCode on all of them. Like this: Controller: _mapper.Map(request); Mapping: config.NewConfig() .Map(dest => dest, src => src.itemCode) .Map(dest => dest, src => src.orders.Adapt()); I get nothing... Empty list. What am I doing wrong? I've tried everything. I'm almost giving up on Mapster. I tried googling it but theres almost nothing about mapster... BTW i'm using mapster to get back a response from an entity and it works. Configurations are working. Thanks a lot for any help!
@Seyanhyriu2 жыл бұрын
I gave up. Went back to manual mapping :D No more mapster
@fieryscorpion2 жыл бұрын
Will you be continuing your DDD video series?
@amantinband2 жыл бұрын
This is still part of the series 🙂 After we get familiar with these libraries and the project structure we will revisit the client application and learn the various DDD concepts while implementing the core logic of the application
@bolafahmi Жыл бұрын
Great series Amichai, btw, I think a better approach for silencing the compiler would be to remove the async keyword at the first place, and in order to return a Task, just return Task.FromResult(any_object_here), this skips the overhead of adding the await/async state machine in IL.
@microtech2448 Жыл бұрын
Hi, is there option to 1. Ignore certain field while mapping? 2. Skip if souce value is null or default of nullable value type 3. Reverse Map?
@turbomen786 ай бұрын
Hi Amichai there any way to use injected service in each mapping config file that implemnts IRegister? thanks
@cherifdiallo5592Ай бұрын
Very nice and helpfull video congrats! How can I use the Mapster package to tranfer all my Product DTO properties into my Product Entity object while keeping all the Entity properties that are not in your DTO with they orignal values. The objective is to pull the an existing item from the database and then update all properties from the DTO while keeping fields like createdDate for example.
@matheustorresdosreis95082 жыл бұрын
Finally! Is it better to use some mapping library or do it manually?
@amantinband2 жыл бұрын
I like this sort of magic. Especially since manual mapping starts nice and clean but becomes quite complex over time. Is it better? Really depends on preference and team
@kennedydre8074 Жыл бұрын
Please what do you se to make your terminal look that cool?
@davearkley70142 жыл бұрын
For DDD I have a private default constructor on my target object with a public static factory method to create the object. Can I force Mapster to use the factory, as currently it throws an exception when it can't find the default constructor. How do you handle this?
@AlexGait Жыл бұрын
It's been a while, but I found a solution. Let's say you want to map a GUID to a UserId with private constructor and public static factory method. config.NewConfig() .MapWith(src => UserId.Create(src)); config.NewConfig() .Map(dest => dest.UserId, src => src.UserId) .Map(dest => dest, src => src.Request);
@MrKlyushin Жыл бұрын
@@AlexGait many thx!!! 🤩🤩🤩
@Talieization Жыл бұрын
How did you apply colors in terminal directory path?
@ppenxhchqlz31132 жыл бұрын
What if I dont want to map default values? Like if the incoming request have a null value and I dont want to map it?
@torrvic115611 ай бұрын
Thanks for awesome video! But what about mapping of one collection to another? I fail miserably. How can we do it with Mapster?
@iliyan-kulishev2 жыл бұрын
Junior dev here, I'm probably missing something, I can't help it but ask: why do we need a mapping library? Regardless of the types being mapped (DTO, Domain, ViewModel, Request for CQRS handler etc.) each mapping happens in one and only one place in the app. So why is manual mapping considered so hard to do all of a sudden? Or if for some reason the mapping from type A to type B occurs in many places in the code (weird), then why not just implement conversion operator ?
@efimov902 жыл бұрын
Amichai Mantinband, 22:36 is await Task.CompletedTask better than return await ValueTask.FromResult()? Looks like crutch, just for enforce IDE to be silent about this.
@amantinband2 жыл бұрын
Hey Сергей, yes, `await ValueTask.CompletedTask` is a bit more efficient. As you said, this is just to silence the compiler for now
@meetingattender81322 жыл бұрын
@@amantinband what about: // TODO: remove await Task.Yield(); ?
@AccupressurewithSudhir2 жыл бұрын
Thanks for one more Awesome Video! Kindly let me know where I can source this on Github if possible.
@DeejayWazzouille2 жыл бұрын
Hi ! I'm having issue with mapping "id" field, any clue ? It's a long type, dont work with "id", but works with 'Id"
@Tof__2 жыл бұрын
Is there repository on github for this project? Cannot find it in description. I would appreciate it.
@nivaldobrasil2 жыл бұрын
Thank you
@larsp51092 жыл бұрын
I like explicit Mappings, there was this great addon vsix called MappingGenerator but its creator unfortunately turned it into a paid extension of which the price is a bit steep…
@cunzhili2100 Жыл бұрын
The brush tool looks very useful. Could you share the name of the software
@kirangrajan Жыл бұрын
Hi Everyone, Any idea what is the best approach to test these Mapster mapping configurations using the IMapper interface?
@AlexGait Жыл бұрын
Hey, Amichai! I am using the strongly typed IDs you introduced later (private constructor and public static factory method). In case I wanted to have strongly typed IDs on my Commands and Queries, how would the mapping from GUID to those IDs be configured? config.NewConfig() .Map(dest => dest.UserId, src => UserId.Create(src.UserId)); public record Command(UserId UserId, ...); This doesn't work as Mapster is looking for a constructor for UserId.
@AlexGait Жыл бұрын
I found a solution config.NewConfig() .MapWith(src => UserId.Create(src)); config.NewConfig() .Map(dest => dest.UserId, src => src.UserId) .Map(dest => dest, src => src.Request);
@DanielTames2 жыл бұрын
Thanks! sensei
@zhh1742 жыл бұрын
One question how do you see the source code of library in vs code? I knew rider had this feature. But does vs code also have it?
I like so much, i don't know this package i always use automapper and i hate it, now i'll use only mapster in my projects
@Marko-the-Beast-Master2 жыл бұрын
Every time I'm trying to make a Request I got error: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1] An unhandled exception has occurred while executing the request. System.ArgumentException: IDX10703: Cannot create a 'Microsoft.IdentityModel.Tokens.SymmetricSecurityKey', key length is zero.
@abhishekbagchi60522 жыл бұрын
Great video as always One thing i did not understand how you go to the metadata classes of mapster from code?
@iliyan-kulishev2 жыл бұрын
Biggest mystery to me too. Watching guys like him and Nick Chapsas doing it makes me feel like a total noob :)
@abhishekbagchi60522 жыл бұрын
@@iliyan-kulishev well Nick uses jetbrains Rider where that functionality already present.. i.e. downloading external code I am pretty sure its not present in VS Code by default so if you just know what extension Amichai is using we will be able to do it to
@iliyan-kulishev2 жыл бұрын
@@abhishekbagchi6052 Well u need to decompile the 3rd party assembly. I've heard about two tools fit for the job: .NET Reflector and dotPeek.
@abhishekbagchi60522 жыл бұрын
@@iliyan-kulishev yeah but it seems in this video it happened without doing any of that
@amantinband2 жыл бұрын
Haha funny thread 😂 I thought it came from the `ilspy-vscode` extension but I don't have it installed. I honestly don't remember how I configured this and I'm unable to reproduce it on my other machines ATM. Weird. I'll have to dig deeper
@robiulhassan42632 жыл бұрын
love your series, but do you have any plan add a logger like serilog? It will be great if you add serilog.
@amantinband2 жыл бұрын
Yup, not sure it'll be as part of this series as it might be too much of a cognitive load, but we'll talk about logging in the future.
@jodainemoore8300 Жыл бұрын
I can't get the Mapster to work in the minimal API:InvalidOperationException: Failure to infer one or more parameters. Below is the list of parameters that we found: Parameter | Source --------------------------------------------------------------------------------- request | Body (Inferred) mapper | UNKNOWN mediator | Services (Inferred)
@jerryjeremy40382 жыл бұрын
What's the advantage of using mediator? I used it once and I'm forced to create command classes and other required classes just to make it work.
@amantinband2 жыл бұрын
It's mainly for decoupling layers and splitting logic by feature instead of "service" classes. But as you said, you'll have many more files.
@LagusAT12 жыл бұрын
I dont know why, but code on line _mapper.Map(authResult) dont use defined map. Response has set only Token, but other properties are empty. I also try add BeforeMapping, but is not called.
@LagusAT12 жыл бұрын
Problem solved, i have class AuthenticationResponse twice in code, so delete one and mapping working. Happy 3 hours 😅
@AccupressurewithSudhir2 жыл бұрын
Please anybody help me why i am getting this error "error CS0246: The type or namespace name 'IMapper' could not be found " . I have added below references
@amantinband2 жыл бұрын
Seems right, were you able to fix it?
@bdowns2 жыл бұрын
Very well! How can I ignore null values from ? I'm in troubles 'cause Config .IgnoreNullValues(true) it's ok when ignoring string null values but When my source object have int?, datetime? or decimal? it full overwrite the destinaton values with null.
@bdowns2 жыл бұрын
It's like .IgnoreNullValues(true) just works for string values.
@zhh1742 жыл бұрын
Mapster is been my favorite for a while. But it's not actively maintained anymore. Hope it get more attraction so that it gets maintained.
@amantinband2 жыл бұрын
It had some down-time but it's maintained again 🙂
@LoZioIAR2 жыл бұрын
Great!!!
@925082 Жыл бұрын
Mapster giving issue with record no default contractor for type RegisterCommand, Please use ConttructUsing or MapWith
@bobek80302 жыл бұрын
When next episodes about ddd?
@amantinband2 жыл бұрын
I think a digestible approach to break down the series is first getting CQRS, MediatR, Mapster, FluentValidation etc' out of the way together with the auth stuff. Then, we can revisit the client application, learn the various DDD concepts while implementing the core logic of the application. What do you think?
@evilTano2 жыл бұрын
@@amantinband yeah, modeling the domain with DDD must have a dedicated video. It's one of the hardest thing to learn.
@glickyaron9490 Жыл бұрын
Great video, from my experience Mapperly is way better.
@MilanJovanovicTech2 жыл бұрын
Dynamic mapping with Mapster is my favorite feature. I really dislike the IMapper approach, because it doesn't bring any added value.
@vagnerpadilha34852 жыл бұрын
can you speak more about this? what do you prefer to user? extension method ".Adapt()" or by dependency injection "IMapper" ? Is there any downside to using the extension method ".Adapt()". the code looks cleaner and more straightforward :D
@amantinband2 жыл бұрын
Well, it depends on your mapping logic. If you have any dependencies, it may be useful to simply mock the mapping. An easy example is something like the following: config.NewConfig() .Map(dest => dest.Name, src => MapContext.Current.GetService().Format(src.Name));
@patrykk.46302 жыл бұрын
We use AutoMapper for mappings. Sometimes it's hard to find out what is wrong with the code.. This one looks like it's more forgiving. And you said it is faster, will check that out 😀
@ucretsiztakipci661211 ай бұрын
IgnoreNonMapped is not working damn it.
@timur288710 ай бұрын
Сомнительно, но окэй... Стал ли код проще? Нет. Стал ли код эффективнее и быстрее? Нет. Может быть в некоторых случаях будет меньше строк кода, вот и весь профит...