🚀 Join the .NET Web Academy with a 30% discount - closing soon! 👉 www.dotnetwebacademy.com/courses/academy?coupon=dnwas23yt
@stephenohaeri2472 Жыл бұрын
there iis something so special about your videos, i am a .Net developer and i will cherish your videos anytime anyday
@andreiene86952 жыл бұрын
13:32 in that case you can simply add .Reverse() and you won't need to write another line
@ericfleet9602 Жыл бұрын
Correct, except it is .ReverseMap()
@PatrickGod Жыл бұрын
Thank you! You live and learn! :)
@10Totti2 жыл бұрын
i also use mapper in this mode: CreateMap().ReverseMap();
@dasfahrer81872 жыл бұрын
Beat me to it. :)
@devtekve13962 жыл бұрын
Tho this only works if you are not doing any explicit mapping for members
@PatrickGod2 жыл бұрын
Btw, we can also use this line to map the heroes collection: *return _mapper.Map(heroes);* 🤩
@ferenc34602 жыл бұрын
I will try to use it ín my HairSalon project 🙂 would you make a video about tricky stuff like sending list of objects to the controller properly and for instance with dynamic objects from the client side? Such as adding multiple skills or items to the superhero. Actually, I can do this stuff but I would watch some concepts from you 🙂
@jayanandajena82682 жыл бұрын
Hi Patrick God, I have watched all of your videos and learned so many thing, so I have a request to you that can you please make a video on 2 factor authentication like we can send OTP to multiple phone number with different OTP and we validate that both at a time. Its a request thank u so much.
@SantiagoDSCA Жыл бұрын
you can try with CreateMap().ReverseMap() it allows the mapping in both directions, so you dont need to add the other line :D
@PatrickGod Жыл бұрын
@@SantiagoDSCA Thank you! You live and learn! :)
@MahmoudMouradSidky2 жыл бұрын
30 degree is freaking hot!!! You should come to Egypt and try the 42 degree
@kopilkaiser899110 ай бұрын
This is the first time I've learnt about AutoMapper and it seems so powerful and useful! This will make it so much easier to convert one class data to another. You are a lifesaver and a gold resource of knowledge. Cheers🎉🎉🎉
@devtekve13962 жыл бұрын
I believe you should also know that auto mapper is easy to be abused and start doing things you probably shouldn’t. That being said, I’m a huge fan of it and use it a lot at production environments!. One big caveat is that auto mapper doesn’t support asynchronous operations, so if you want to do resolve some things asynchronously it won’t help you there. There are things you could do to make that work but beware it’s not intended for that. Another thing also worth mentioning is that auto mapper is slow, I believe it uses reflection, but hasn’t been a problem for me anyways. One more thing, your object will require a parameterless constructor to support automapper. Would be interesting to see a video about alternative approaches to Automapper that make your life as easy as it does
@micha84692 жыл бұрын
I sorta agree. I used to use it almost in every project, that wasn't really my, but rather team/head's decision, and I am glad I don't use it anymore. There is literally nothing in it rather than more code that you have to (should) cover with tests and things that can go wrong underneath. - If Entity->Poco mapping is easy then manual mapping is also easy: entity.Select( x => new Dto() { fill props} ); - If Entity->Poco mapping is complex, the manual mapping is more difficult, but is safer and you have full control over it. With Automapper, you need good tests to make it safe. Either way a manual mapping has a slight advantage in my opinion, not to mention performance factor. There are many articles about Automapper issues and flaws, no need to list them here, everyone interested can google it easily. Do you know any people who resigned from it and came back to it again? I honestly don't unless it was forced to us in a project.
@SebVEVO2 жыл бұрын
@@micha8469 I disagree that it has nothing in it because it happened so many times that when a feature or even a minor change is made, people often forget to update the Mappings that leads to direct or unseen bugs. Maintenance in medium-sized projects can even be taxing. AutoMapper solves those issues by removing all those Mappings methods. However, AutoMapper should not be used because of Performance and Diagnostic issues especially in production.
@muttBunch Жыл бұрын
Amazing tutorial, thank you. Oh and nice shirt!!! I love how it looks sandy for a beach shirt.
@PatrickGod Жыл бұрын
Thank you very much! Fun fact: I actually got the shirt in Hawaii. You know, close to the beach. 😅
@minashokrallameichael59982 жыл бұрын
Great topic I am a big fan of you, small note I want to add you dont need to convert to Dto one by one using linq, Automapper support collection
@PatrickGod2 жыл бұрын
Awesome! Thank you very much. You live and learn. 😊
@minashokrallameichael59982 жыл бұрын
@@PatrickGod sure and really I like your way of explaining, congratulations really
@properwaffles Жыл бұрын
Thanks!
@PatrickGod11 ай бұрын
Thank you!!
@nguyenhuuanhtuan5360 Жыл бұрын
Thanks for the detailed explaination, I did some google search about automapper for my project but your video made it so clear for me ❤❤
@fshyjp2 жыл бұрын
Thank you, Patrick! This is right the information that I wanted.
@theodorn2 жыл бұрын
Thanks a lot! Take a vacation in Sweden, it's cooler. 😀
@zulhishamtan4308 Жыл бұрын
Hi Patrick, thanks for the video. My question may sound stupid... Anyway, I would like to know when was the AutoMapperProfile class being call? When was the createMap statement being executed? Appreciate if you could make my mind clear. Last but not least, could please make a video for authentication webAPI.? Thank you very much.
@raggardy2 жыл бұрын
Hi Patrick. Great video. I was wondering if you've ever used Mapster? What are your thoughts if you have and maybe that could be a video for the future?
@davidheale64352 жыл бұрын
Mapster for the win.😄
@PatrickGod Жыл бұрын
It's great! Even easier to use than AutoMapper. We will use it in the .NET Web Academy. 😊
@aagastyapathak2 жыл бұрын
Thanks, Patrick Always learning great thing from you
@khalidracabov53472 жыл бұрын
Love you so much dude. Keep up the good work
@PatrickGod2 жыл бұрын
Thank you! ❤
@svenkicherer2 жыл бұрын
9:17 could you explain why you are using the linq statement? what is the benefit? you could just return _mapper.Map(heroes)
@PatrickGod2 жыл бұрын
Because I didn't know that. 😅 Thanks a lot for sharing! Works like a charm. 😊
@svenkicherer2 жыл бұрын
@@PatrickGod sometimes automapper is really nice 😉
@divanvanzyl7545 Жыл бұрын
Hey Patrick, love your videos. As a South African, I always laugh at Europeans who call early 30 degrees hot😂 try 40+ celcius, then you can talk😂 I had the privilage of visiting your amazing country this year and I highly reccomend it to any traveler. Thank you for all your great content. Ive learned a lot from you, as have so many others.
@PatrickGod Жыл бұрын
Awesome! Thank you so much. Where in Germany have you been?
@franciscogilt2 жыл бұрын
Patrick God -> 0, VS2022 - 5, The Battle xD, Overall awesome introduction to Automapper.
@PatrickGod2 жыл бұрын
Indeed, it's a battle sometimes. 😅
@skg79582 жыл бұрын
Thanks! Patrick. As always, love your topics and presentation
@HenkvanderGeld Жыл бұрын
Hi Patrick, can there be a reason to use separate DTO's for [1] transferring data from client to server and [2] transferring data from server to client. For all of our models (250+) we have 2 DTO's; so for e.g. model Employee we have EmployeeReadDto and EmployeeEditDto. This also means that we have a lot of mapping configurations; Employee -> EmployeeReadDto, Employee -> EmployeeEditDto and EmployeeReadDto -> EmployeeEditDto. Most of the time the difference between the 2 DTO's is only the Id property (xxxReadDto has an Id and the xxxEditDto has not). Having the distinction brings a lot of extra code and configuration. Is it really necessary to have this distinction or can everything be done with 1 dto, e.g. EmployeeDto?
@marciliojrr Жыл бұрын
I need this too
@torrvic11568 ай бұрын
Very good question. I think that it should be separate but I am not experienced so I would like to know this too.
@IDotWood Жыл бұрын
Hi Patrick. Can you explain how it just works after creating the AutoMapperProfile class? Perhaps I missed it but I didn’t see you initialise or inherit that code anywhere. What am I missing?
@todo667 Жыл бұрын
7:29 He's using dependency injection and adding an IMapper interface in the SuperHeroController constructor
@Lukindify2 жыл бұрын
If you use mongodb, you don't need to use an automapper to return. The mongodb driver already have a translator, the extension "As", and you can use the extension "Lookup" to manipulate fields.
@chesster59812 жыл бұрын
Yeah but js is gross af 🤮
@abdulmussawir3132 Жыл бұрын
Hello Patric Hope you doing well, As per your thinking Auto Mapper Map Performance it's slow or not ?
@waynehawkins654 Жыл бұрын
Thanks for the video. This is like many I have seen, and all use API with EF. What I like to see is full EF without API, using Class calls to Add,Update,Deleted DTO changes in EF. I have all working, but when I try and do a Update by passing a DTO back in to EF to do a update, I get errors. I will keep looking, but I hope to find a full video solution that show how to use EF with DTO and AutoMapper without using APIs.
@junior.santana Жыл бұрын
Have you found what you were looking for? From my understanding, your issue is not related to API, you shouldn't pass the DTO to EF since it's just a "Data Transfer Object", you should map to the corresponding entity and then pass that to EF/DbContext
@dantecavallin82292 жыл бұрын
What about if the two types are in different assemblies? Isn't that a more realistic usecase?
@imadabab5 ай бұрын
Brilliant video. Thanks a lot.
@starswarslandoseries Жыл бұрын
Thanks Patrick, You are a God
@markgamal72502 ай бұрын
where i live it is 40 C degrees in summer in a usual day
@huynhthanhliem11x13 Жыл бұрын
ty
@oveskhan687 Жыл бұрын
Hi Patrick, we would like to see tutorial video on .Net 6 Azure :)
@Duelweb2 жыл бұрын
Brilliant!
@raphaeldevmtb2 жыл бұрын
Great! Thanks
@PatrickGod2 жыл бұрын
You're welcome!
@James66662 Жыл бұрын
Thanks dude , works perfect
@shuvbhowmickbestin Жыл бұрын
30 degress *freaking hot* 🙂🙂. Europeans don't really use air conditioners, do they? Also really nice video. I previously did a Udemy course which explained everything perfectly but didn't mention *WHY* Mapping profiles were used. So you showed us that here, it's basically like a policy/rule that allows the mapping right? but the real mapping happens with the *_mapper.Map()* method. Thanks a lot for the video.
@farhanpirzada4228 Жыл бұрын
how to install this package in class library project ??
@AliFrazK2 жыл бұрын
Nice.
@PatrickGod2 жыл бұрын
Thanks!
@TommiLipponen2 жыл бұрын
How to handle related data with automapper and DTO:s? Like if there is a table for super powers that every hero may have one or many. How to get a list of super heros including their super powers when using automapper and DTO:s?
@ericfleet9602 Жыл бұрын
13:40 - Instead of two lines, just use .ReverseMap()
@harchizia Жыл бұрын
Is that really work?
@stephenhauck2 жыл бұрын
I really like your content so thanks but why would I use this when it can obfuscate the names of properties when transposing them between objects when I can just use Newtonsoft or MS code generators and convert them using JSON property mapping ?
@denis-gd1xc2 жыл бұрын
Great video, if I have multiple entries other then the superhero, I will need to create multiple profiles or I can create it all in the same profile?
@PatrickGod2 жыл бұрын
Thank you! Should work in the same Profile. Just add the other mappings there. Cheers!
@choripower Жыл бұрын
In profile u can add .ReverseMap(); so u dont copy code
@denis-gd1xc2 жыл бұрын
Hey Pattrick, the automappers faills only when i try to get the object by id its same error as in the vid its strange becase the getall method work and its same mapping do you know why this pronlem occurs?
@eradubbo Жыл бұрын
Automapper = instant technical dept
@sahildhingraa Жыл бұрын
!completed
@Simao-xk1ye2 жыл бұрын
Thank Patrick for this topic, what if we dont want to map some properties of dto ?
@denis-gd1xc2 жыл бұрын
Hey Pattrick, im writing a project and i have a class library that has all the repositories and i want to map from the repository itself and then return the value, how i can do it?
@jadissonamorim60102 жыл бұрын
Patrick, could you record a video about DDD (Domain Driven Design)?
@PatrickGod2 жыл бұрын
Noted!
@meirkr Жыл бұрын
Is there a place to map also mapping between models and DB entities, in order to hide DB related stuff (special properties for Mongo or EF core)?
@stevemcqueen2887 Жыл бұрын
hahaha "Visual Studio, Jesus Christ... what is going on here?" well said 🤣🤣🤣
@ACertainWebDeveloper2 жыл бұрын
Can I create an universal AutoMapperProfile? Like if I got 50 models, do I have to create 50 AutoMapperProfiles?
@marciliojrr Жыл бұрын
Hello @PatrickGod, First of all, I wanted to say that your video was excellent, just like all the others. I was wondering if you could explain to us how to use AutoMapper for entity editing. In the system I'm developing, we use a DTO to add a new entity (for example, SuperHeroDto), and in the Service layer, it is transformed into a "regular" entity (SuperHero). This works well. However, I have some doubts when it comes to editing an existing record. The issue arises because, during the post request, it uses the mapping configuration from when the object was created. As a result, some things that should be preserved are changed (e.g., Id, Creation Date). It might be something simple, and I might be overcomplicating things, but if you could help me understand how AutoMapper works for both adding and editing entities, it would be immensely helpful in advancing my projects at the company where I work. Currently, the mapping between DTO and the "regular" class is done manually. Thank you very much and best regards.
@Beji-boy2 жыл бұрын
I wanna ask if you using Automapper so how you use Entity Framework ? Which differents is between Automapper vs Entity Framework. And if I wanna use Automapper and Entity Framework in one project. So Which one is good use it? Thanks for answer
@devtekve13962 жыл бұрын
Entity framework and automapper serve two different purposes. Automapper is just a convention based object mapper, while entity framework is meant to manipulate the objects and persist them on a backend while treating them as simple objects (not worrying about database code [too much anyways …] ) You can use automapper and entity framework together. If you do the mapping the way he did it on the video, you’ll be creating a new object with the properties mapped from the other. However, you can map the properties of one object INTO Another object, which is essentially like manually assigning the properties to the existing object, which is what entity framework wants. You do this by doing something like _mapper.map( source, destinationObject);
@softwareenthusiasm36672 жыл бұрын
Tried to AutoMapper.Extensions.Microsoft.Dependen and got error Severity Code Description Project File Line Suppression State Error Package restore failed. Rolling back package changes for 'AutoMapper'.
@stevejackson2643 Жыл бұрын
Visual Studio clearly doesnt like the heat either
@sphazwelakhe27842 жыл бұрын
Hi Patrick, can you please demo a [HttpGet] method for updating existing model with Automapper.
@king_naashik92662 жыл бұрын
Hello sir can u do a .net crud programme with clean Architecture
@farhanpirzada4228 Жыл бұрын
when i trying to install its throwing error cycle detected
@amichelis2 жыл бұрын
Why not writting a simple explicit typecasting opperator from SuperHero to SuperHeroDto and just do "return Ok(heroes.Select(x => x as SuperHeroDto));" ?
@amichelis2 жыл бұрын
Could also work with heroes.Cast(). Also, you ommited the ID from your DTO. How did that worked when mapping from DTO to Entity?
@mhdip64532 жыл бұрын
i m just watching everyone automapper tutorial everyone just showing how to use automaper to fetch data only one table i don't find any solution.. when it comes to the join table .. How to use join with automapper.. can you make video about this.
@bramburn2 жыл бұрын
You have any T-shirt I can buy
@mohammedalbosifi39752 жыл бұрын
We want toturial about identity server 4 and than you
@devalefsilva2 жыл бұрын
.ReverseMap()
@Synergy_World2 жыл бұрын
33 is nothing in South Africa 🇿🇦🇿🇦we currently on 120degreess
@philipm18962 жыл бұрын
Sometimes I wonder if all these overhead bulky tools for making SQL queries are even worth it when the raw SQL queries are x10 faster and configurable on the fly.
@SupahSamie2 жыл бұрын
Not as safe though, wouldn’t you say?
@philipm18962 жыл бұрын
@@SupahSamie Very safe if you use add with parameters if parameters are passed in.
@SupahSamie2 жыл бұрын
@@philipm1896 Yeah, not just injection safe is what I’m saying. The ORM makes writing queries safer I thought but I could be wrong
@yashwanthd19982 жыл бұрын
More readable and maintainable and it is not slow . Using raw queries is pain use to do in php
@krillcasey2 жыл бұрын
It seems like a lot of work ....
@GoryWory Жыл бұрын
superheroes? how old are you, 5?
@mahfujurrahman1016 Жыл бұрын
spider man's place should me Brooklyn
@bananasba2 жыл бұрын
You'd better think twice before start using automapper for anything serious. Authors of this library will always say that it is your fault, your problem and you are using it wrong and you will be left alone with this tool and your problems. They also like to do breaking changes without any option for fallback. No library should dictate you what to do in your own code.
@dputra2 жыл бұрын
Wow really? That surprised me. I was gonna use it for my future projects but seems like we'll stay away for anything serious.
@Erril_Ferndal5 ай бұрын
Please stop using Automapper, it looks good at the beginning but it cost us so much more time and nerves in the long run. It's totally not worth it! If I wanted to not have references in my mapping code, I would have used plain JavaScript. 👎