Minimal API CRUD Actions using Entity Framework Core | Minimal API File Upload | .NET 7 Updates

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today let's talk about minimal apn.net 7. so this is the new feature introduced in dotnet6 in.net sub and it is much improved the minimal APR architecture to create the HTTP APA with minimal dependencies so here I listed out all the steps we can go one by one so first I am going to create one basic minimal APA so there I am going to use different data types and we can change the input description type and the next I am going to use the NDT framework in minimal APA so using this Entity framework we can complete the credit operations once it's completed we can move on the upload functionality so in this upload point of view we can upload single file and multiple files at the end we can see the advantages in minimal APA and also it is having some limitation so these things we can discuss at the end of the video okay now let me go to my application here we can Define our minimal APA so in this application let me go to our program.cs file so here I already have added this Entity Framework I will share that video link also in the description if required you have to watch it first I am going to include one get method so this is one of the very very sample method it is just returning on string data okay now we can pass some parameters so let me copy the same thing first I am going to pass one string value so now we can run this application we can verify whether it is working fine or not so if it is working fine we can move on the next topics okay so see we have the first method is basic get so okay great it is returning the data the second one it is expecting one input so welcome to test okay it is working fine now I am going to provide some description for this input okay for that we can use this open APA parameter dot description provide channel name okay let me execute this one see so whatever text we have provided it is coming a server input a description name okay and the same way if required we can use the rate limiter also for doing this one we have to use this require rate limiting and then we have to provide the policy name so we have defined a lot of policy okay these are the basic steps in minimal APA now I am going to use this Entity framework so using that we can complete our credit operations so first we can start from one get method so this is for returning all the customers in our table so I am going to provide get to all customer so this is our method name and the input I am going to provide our database context DB first context okay so here I am going to return the list of customers DB Dot table customers tattoo list okay okay basically this will work so if required we can use this asynchronous function also for making this into a synchronous you have to use like this okay so instead of this list we can use to list asynchronous and also let me include the summit okay this is fine so let me verify this one so if it is returning the data our connectivity and everything is fine so we can move on the next action method okay okay great it is returning the data so next I am going to create one more APA for get by code so the method name is get customer by code so it is having one parameter the parameter name is ID okay so instead of this complete list we can return the single data find a synchronous confide okay this is fine so definitely it will work so anyway I will complete all the functions in the coding level so at the end we can test one by one okay so next I am going to create one post method so this is for creating the customer so for the Post method first we need to change this one instead of this map get we have to change into map host okay and this is create customer so the input is an object table customer first I am going to add this object into our table we can use this add a synchronous so once it's done we have to save this one save changes of asynchronous okay so now we are good about in this creating the customer next let me move on the update method so it is having the ID parameter also and we have this object also okay so instead of this post let me change into put okay so first we can get the existing data then I'm going to check not equal to null if it is fine we can modify the data so I am updating just to three Fields only so once it's done we have to save this one okay save changes so we have completed this put method also the final one is delete so let me copy the same code so instead of this update let me change into delete customer and also in our method type we can use this smart delete okay so here this object is not required so other steps are almost the same only if we have the data we have to remove this one so DB Dot table customers that remove here I'm going to pass the existing data that means our existing customer information okay great we have completed everything in this coding side now I am going to run this application we can verify one by one so first ever create customer okay so the first field is the identity column so let me remove this one so let me execute this one we are just passing on Object online okay we are getting this 200 response that means it is working fine so I'm going to execute this Gettel customer see now we are able to see this CMS journey and it the complete information so the new edition generated is 18 okay so let me copy this ID so we can check our next function get by code here I'm just provided 18 so it is returning the in digital object okay so if I'm given 19 so basically we don't have the data so it is written in null okay now let me copy the same object we can check our update method so first our object okay so next in our ID 18 so we can do some changes so we have changed the name and also email ID so in the phone number at the end I am added one okay so let me execute this one okay great and here also we are getting the same response 200 so let me verify our get all method see the name is updated and our email so even the phone number at the end we can see this one so the final one is delete so I'm going to provide the same 18 right so here also the response is 200 see now the data got removed okay so our delete function is working fine that means we have successfully completed our trade operations now let me move on upload functions okay so the upload point of view we can upload single files and also multiple files for the single file upload we have to use the interface of I form file add the multiple files we have to use iPhone file collections okay so for this one I am going to use one post method and our method name is upload and this one also a synchronous method our input is iPhone file so here the first thing is B how to define where actually we are going to store our files okay file path equal to upload so inside that we can create our file in the same name whatever files you are uploading we can use the same name okay so that we can get from our input file itself file.file name okay next let me use the string open for right so here we have to specify our path okay so finally file that copy to a synchronous string okay we have completed the functionality so enough and also in our application we don't have the folder of upload so let me create this one so now we can run our application so see we have this upload action method so here we can choose our Channel logo okay the response is 200 let me go to the exact path see we have our company logo okay so I'm going to upload one more file jQuery so both the files got uploaded successfully so next I am going to implement the upload functionality with multiple files so this is the very easiest one so we are changing this input interface so after that I am going to make one for Loop that's it I form file collection I'm going to generate the forage okay we have done let me exceed this one before that I need to change this function name multi upload okay so see first I am adding this Visual Studio logo next vs code logo so finally our APA logo so totally I have added three files now I am going to execute this one so see the response again we are getting this 200 that means our upload is working fine see the folder we have these three files okay and here we can modify the Logics like the file is already there we can delete and recreate the file and if required we can change the file name also for changing the file name so whatever name you are trying to provide in this place you're supposed to give okay and before going to this copy you how to check like you file is exist if something is true we have to delete and recreate it okay so this is all about the upload functionality now let's discuss on some advantages in this minimal EPA so the minimal AP also a kind of rest AP only it is reducing the ceremony to create a new APA and without the controller we can complete our functionality it is faster compared to MBC as the bootstrapping that is required to build and compelled application so as much as possible it is simplified and also it is having some limitations okay
Info
Channel: Nihira Techiees
Views: 2,775
Rating: undefined out of 5
Keywords: Minimal API in .NET 7, new features in minimal api, how to use Entity framework in Minimal api, CRUD actions in minimal api, CRUD Operations in minimal API, what is minimal API in .NET Core, how to use rate limiter in minimal api, how to change input description in minimal api, What is new in .NET 7, file upload in minimal api, limitations in minimal API, IFormFile in Minimal API, IFormCollections in Minimal API
Id: tTp-kCZwXEA
Channel Id: undefined
Length: 17min 52sec (1072 seconds)
Published: Mon Dec 12 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.