miercuri, 26 septembrie 2018

Use of AutoMapper in Web API for DTO (Data Transfer Object) or ViewModel (ASP.Net Core) with example

https://bit.ly/2N9wMPP Secret sale page ICopyBot.
Follow on : Website 1 : http://www.imrezratin.com/ Website 2 : https://thumbikr.blogspot.com Fb Page : https://www.facebook.com/thumbIKR.official/ How to use #AutoMapper for DTO (Data Transfer Object) or ViewModel in Web API (ASP.Net Core) step by step with example Using AutoMapper for object and object view model. Steps : 1. First of all install AutoMpper NuGet Package. Installation Done. 2. Now I am going to create a ViewModel of class Student. 3. In StudentViewModel I never want to show Id. StudentViewModel done. 4. Now I am going to add Mapping in ApplicationProfile class. CreateMap done. 5. Now goto startup.cs and register AutoMapper. Registration Done. 6. Now I am going to apply AutoMapper in StudentsController. 7. HttpPost done. 8. HttpGet Done. 9. HttpPut Done. 10. For HttpDelete Mapper no need. 11. Now I am going to test this example. 12. First open SQL Server management studio. 13. Now open postman for test this example. (This example is on Web API) 14. First : test HttpPost. Output showing Id and Name. But I want to display only Name not Id. Now I am going to hide id using ViewModel and Mapper. Now we can see only Name. HttpPost Done. 15. HttpGet, I am going to test. Id not showing. HttpGet done. 16. Going to test HttpPut. Name updated and output does not showing Id. HttpPut done. My other tutorials : a) CRUD Operation using Entity framework core - Code first procedure : https://www.youtube.com/watch?v=QR81oud0NAc b) CRUD operation using Web API (Http Call) in ASP.Net Core with Example : https://www.youtube.com/watch?v=zy-Ys82RRfc c) CRUD operation using MongoDb and Asp.Net Core https://youtu.be/chhjsvl5cVc d) Code first procedure in Entity Framework Core : https://www.youtube.com/watch?v=40wOEJFWEdI&t=3s If you like this video then subscribe my channel and LIKE this video. Thanks for watching :) #WebAPI #DTO #DataTransferObject #ViewModel #ASP.NetCore #ThumbIKR