Learn C# with CSharpFritz - Building APIs with ASP.NET Core

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
test there we go that was weird there we go that was weird there we go that was uh there we go that was weird okay uh something's messing with my sound board is what's going on here how you doing there friends wow the fun we have when you step away for a week and then you come back to stream and then weird stuff happens good morning good afternoon good evening it's so good to see you my name is jeff fritz today this is another c sharp with c sharp fritz and uh it's it's december 13th 2021. this is going to be our last stream of 2021 we're going to get in and we're going to write some some code today we're going to learn about apis let me say hello to all the folks that are here in the chat room hello hello it is so good to see you there the chat room's right over here let me say hello uh ancient coders here exe good to see you francesca francesco francisco in ghana hello hello yes we got we got the sound it's it's not going to work without it of course um how you doing there nick on on youtube carl edwards you've gone deaf i've gone mute uh yes we we've got that all fixed um how you doing there mohammed in libya good to see you um let me see here uh adam runs hello hello dice vdd hello here to learn that's great because i'm here to teach it works out nicely like that let me keep scrolling through here exe help says welcome to monday yes uh i was gone for a week i was speaking at a at an in-person conference i was at the dev intersection event in las vegas last week an in-person event um it was also co-located with the microsoft m365 event and um a tremendous amount of content um about 2 000 people were at were at the events we had a bunch of speakers there so good to see folks in person so good to see attendees in person connect discuss things i had a number of very productive meetings that week so good to see folks getting back to it getting back to normal in-person event that doesn't mean i'm i'm going to stop streaming here not at all i i reach significantly more people streaming here than i do in person and and of course there are folks who just wouldn't be able to make it to in-person events at the locations that i'm able to go to so being able to connect with you wherever you are is of utmost importance to me how you doing there bruce lane let me continue rolling down the list here del riverson polyetta what topic are we going to talk about today it should say just below me here whether you're on twitch you're on youtube uh you should see that for some reason learn tv is not broadcasting me today i don't know why um i tried to connect and it is not accepting my connection so we are not on i'm gonna i'll try it one more time but learn tv is not broadcasting me today as we try sending data sending data and no this doesn't look good nope cut me off all right we won't be using them today um how you doing there adas and lithuania let me tell you what i'm going to put up the i'm going to put up the timer here um it's right there and make sure that that we go through and and and we limit our our opening ama here for the next 40 minutes you love learning but your brain doesn't lost wages nah nah um when is clip talk gonna be available open source it will not be um sorry that's not something that we're that i'm going to be publishing that's something that i've been writing and i will not be publishing the source for that sorry aj is here from india hello hello uh vvg online fan of the belgian football team that's terrific uh are they playing or is there something going on there that i'm missing um all the best to you and your team um i've been i started watching um i started watching ted lasso on apple tv over the last week and uh i'm in i get it i totally get it makes sense um i i knew a little bit about uh english football culture and um it's been a lot of fun taking that that dip into it so max hello to you in london uk yes world cup 20 22 coming up uh in in qatar we'll see our our american team here we'll see if they if they get out of uh the concacaf region here out of the confederation of north america central america football region um last last time around they didn't make it they didn't make it in 2018 into uh into the finals but um so far so good looks like we're gonna make it out it looks like we might make it out with canada and mexico might need to go into the playoff round um with uh who is it it's somebody from the from the oceana region um but long way to go before that's all ironed out though um craig's tuning in from birmingham anderson from brazil uh yeah brazil there's a there's a side that doesn't have to worry about qualifying getting through my gosh the clone me ball uh region brazil pretty sure they're going to qualify brazil argentina couple others the usual suspects you see qualify from that region that are really good teams um so enrique how you doing there in there you go argentina uh is that is that duke is vietnamese tuning in it's so good to see you the u.s women team women's team won the last world women's world cup they did yes and and the the american women's team has been very good in in international play the men's team not so much with that's the that's the one that's going to be the the tough nut to crack here for us to get through uh hello to you so safian in india uh oh my gosh if the states go up against germany forget it we're done um carl is is i thought you said you were from somewhere else no i'm sorry i was looking at someone i was looking at a different name carl's dialed in from south africa um yeah welcome to football chat i'm your host jeff fritz and i'm an american i'm not exactly probably the first person that should be chatting about football um we're going to be talking about building apis with asp.net core today we're taking that step that first step out of building console apps working with um working with notebooks learning a little bit of c-sharp and we're going to start to layer some things on top of it we learned a bit about entity framework core in our last two streams we're going to take that knowledge i want to introduce building apis quickly and easily with with minimal apis i've started calling them mapped apis because that's that's really the syntax that you use with this and let's take that combined technology and see just how easy it is to get started and and be productive with dot net six this is a new pattern that has been introduced in the last the last few months with the dot net six release folks were talking about this as early as um may june july of 2021 but it was um it was evolving at that time it still wasn't complete but now that it is rtm let's talk about it a little bit let's get into this and and see what we can what we can learn get you productive with building apis because there's a number of other folks out there that build apis and other technologies that don't have quite the ceremony that asp.net used to have so i want to be able to show you this and we're going to get in and see just how easy it is to get started when we return in january we'll get into building user interfaces and some of the more interesting web frameworks with asp.net core so let's answer some of the other questions that are coming in here craig says as an englishman happy i'm calling it football and not soccer um i can appreciate that the international audience prefers to call it football um and and when i am speaking and i know that i have an international audience like i do when i'm streaming i will pivot from american football addressing that as just football to soccer and calling that football first um the the and you i will slip every now and again um but i do do try to keep that of note let me tell you how sad i am that that our our side here in philadelphia uh uh union philadelphia union um demolished their way through the playoffs uh amazing goalkeeping um really good strikers playing on the team got to the third round of the major league soccer playoffs conference championships and that week six players on the team six or seven players on the team were diagnosed with covet all went to the bench all were were sidelined um including our best striker our starting goaltender literally he was goalkeeper of the year last year in the league he should have been goalkeeper of the year this year and didn't and we fell 1-0 to new york city who ended up winning uh winning the trophy the following uh this past weekend so disappointing that that our best players were sidelined so we didn't qualify for concacaf uh play this coming season but i think that might give them a little bit of rest and give them a little bit more um space to work let me go through a couple of these other questions what's the difference between razer class lib and web api asks vvg online razer class lib is a way for you to package um components user interface components in it as a new get package they can be shipped and then referenced by asp net core applications and blazer applications risky code asks can i discuss how secure the api no i i avoid security in these sessions um i will show you where you can place the the authorize attribute but authorization is something that my friends on the 425 show christos covers very very well configuring because that is a extremely deep topic that i do not want to touch because there are many many different permutations of it and the the short answer is you dr just drop an authent and off authenticate and authorize um you drop an attribute on the api and it'll it will enforce that um lens on youtube is a fan of asp.net core developed uh their lms and it's working right lms help me out with the uh with the three-letter acronym yes this is a release to manufacturing this is a release too many it is working very well um uh is that saint s on youtube would like to understand how we can run a net application that runs on mac you just built it what goes on with linkers loafers and compilers loafers what shoes are you talking about here how's it different from the windows runtime it's a little bit deeper than we get into here learning management system uh okay um so on on mac it it deploys a runtime and hosts inside of it the same way that it does on windows and linux it's exactly the same nothing different with it if you decide to publish as a single base as a single file application it it pulls everything in it it does tree shaking linking and pushes everything into one exe fi one executable file that gets deployed to mac um am i gonna show jot no um like i just mentioned it's a little bit further a little bit further down than i want to go to and i there's folks going to be broadcasting later today uh the rest of the week christos does a fantastic job covering that content um how you doing there one lion um yep we'll talk about post put delete let me get some music playing here in the background um i'm going to go to the edm playlist today this is stream beats now let's go further down here start somewhere a little bit further down um yeah this is called cozy this is music that's royalty free dmca free that you can use wherever you'd like facebook twitch youtube doesn't matter it's free for you to listen to no royalties no rights being enforced just listen to it have a good time you can even download songs from them or you can listen to them on a playlist on apple music amazon music or spotify like i am check it out streambeats.com thank you so much to harris heller for making this music available for us to listen to today is the twitch stream lagging behind i don't know might be could be um i broadcast a restream on mondays and it just gets broadcast out to everybody um yeah a little cozy edm yeah a little bit of fun a little bit of pep in our step here um so all right can i have a session using dockerfor.net absence one of the options when creating a project tell you what tg i'll put our api in a docker container that we build today how's that sound does that work out for you is that is that something that'll work i think that'll work oh my gosh try thank you yes oh oh you are too climb chat room i i really appreciate the applause um uh regregisty asks why and when we should use minimal api whenever you'd like you have the option of using um using a minimal api that syntax it's been available in asp.net core since 1-0 it's always been there you can use it whenever you'd like i i like to think that when you're building an api something simple or even if it's something complex you're building a user interface in front of some domain logic some business logic maybe just a simple interaction with a database or a cue so you're gonna have that code written somewhere else that you might be using for a front end of a web application well just build a simple api in front of those things so that mobile applications or other applications that you want to be able to interact with with your apis with your back office support systems can make queries into that uh whether it's fetch data or insert data or whatever it might be and interact with that in in an appropriate way that fits in with the rest of your application system uh which is used more wcf or web api in production it's pretty close wcf is certainly being rolled off because folks have migrated and updated to web api so i'm going to have to lean into w to web api but wcf is certainly it it was and is a lot of places out there um you love the connection to the simplicity to other endpoint frameworks out there seems like a great step facilitated by the open source movement started with satya nadella says bryant um satya certainly is is ceo of microsoft um but there very much was an internal um small group that was pushing open source for a long time um led by scott guthrie um that drove that and um satya and the folks approved and said yes let's do this but uh i would give scott guthrie scott hunter um scott hanselman other folks named scott um credit with with initiating that open source movement and certainly satya encouraging and saying you know what this is a a pretty cool way for us to to reach the microsoft goal of of helping everybody achieve more right that's that is our our our directive is help everyone achieve more not help folks that that use this piece of hardware use this operating system use this cloud service no help everyone achieve more i don't care whether you're using a technology that that that isn't.net you're using a tool other than visual studio i want to make sure that you're successful in your career growing in whatever solutions it is that you're building building whatever apps that are important to you i want to make sure you have the ability to achieve more can i have sessions andy asks can we have sessions about incremental source generators um that's way far along in advanced topics um let's see if we get there it won't be until later in 2022 but we'll see a laugh track i i could i could use a laugh track that'd be that'd be pretty cool um let me see can a minimal api serve soap style responses for legacy applications are you kidding me soap um no sorry um soap style applications are not something that we we support with asp.net core um there's fantastic uh features capabilities you can use asp.net framework asp.net 48 and the asmx file structure to build soap-based services not many folks are are using soap um going forward today um um the bach asks on from youtube can i host an api in a different machine and call it from another client from another ip address absolutely yep that's exactly the uh the types of scenarios we want to make sure that you can support build install it with docker and deploy to to your favorite cloud service and i hope your favorite cloud service is a nice fluffy blue cloud that you can deploy to and and host it there and set up gateways and routing around and and redundant um services in various data centers around the world absolutely um you pumped to hear this right now brian well thank you appreciate that uh exe sorry the the scot command doesn't work on this channel um bulat uh i'm sorry uh bogey is that bihogi a bogey i'm not sure how to pronounce it boji in india hello so good to see you welcome in um bulat um says salaam jeff hope you are well what tech is more preferable for building apis in my opinion oh data or graphql and why okay i i've i've been looking at graphql more and more and it it's come on it's a leveled up it's an updated version of odata it does exactly the same things um and it's going to hit exactly the same problems that odata had it's just a matter of time until somebody exploits it the exact it's upset it is susceptible to the exact same problems that oh data had i'll leave that to you to go and figure out which where those problems are and how to exploit it but they're there they're totally there um but which one is more preferable today in 2021 graphql is preferred um i i disagree with that i think it's it's a mistake i don't um i don't like what they've been doing with that technology it gets me too coupled to a database it gets me it gives too much insight into the the structure of my internal systems and and access to those internal systems to folks that are querying it so um my personal opinion i i think the odata folks have learned and built a fine set of capabilities around it i would still build an abstraction something like grpc or open api in front of it how you doing there pc nerd um a csang microservices are essentially web apa web apis and net yeah yeah that's a little bit of an oversimplification but yeah um registee23 on twitch asks what's the difference between a restful api and a minimal api minimal api is built with one line in in your code and you're gonna see how we do that map get map put map post map delete i've taken to calling them and and i did see ancient coder liked i've taken to started calling them mapped apis i think minimal api it it minimizes it it doesn't give full appreciation of what it does but these mapped apis that that you have just map requests from a from a what looks like a folder location from an http endpoint into a method that is going to be executed and some status some data um perform some interaction and and return that that information appropriately to a a caller restful apis um represent representative uh state transfer no i forget what rest stands for now why am i forgetting what rest stands for um restful interactions are are end points that don't that you can query and get back uh json xml you can specify your data type coming back um you get that feature from minimal apis in asp.net core we did a lot of that with controllers before but by doing it this way with middleware with these map statements much much faster and for folks that are coming in from other technologies it looks exactly like how they've been writing code and here's the thing it's 10 times faster it's 10 times faster are you kidding me do it why not so um let me see here there's a nuget package that allows soap-like responses yeah you can you can layer stuff into there but it's not something that that we're actively promoting because folks should be moving on to the more modern technologies um polyetto says my project is using asp.net framework and entity framework six is it worth migrating to asp.net core and ef core oh yes oh oh yes you're going to see immediate speed improvements stability um security improvements you're going to see technology improvements like you're going to be able to build and deploy with docker you're going to be able to build and deploy on your favorite operating system windows mac or linux build wherever you'd like deploy wherever you'd like you want to build that application and deploy it to linux no problem we got you covered you want to deploy it into the cloud in a kubernetes cluster that scales appropriately as needed we got you covered the upside of upgrading to asp.net core is tremendous check it out absolutely i would suggest you do that what's the main difference between microservice and web api asks a j um i would i would suggest that microservices have more to them than just an endpoint um and that's why i've been calling these mapped apis and not microservices there are folks that say microservices have their own isolated database and and uh not just datastore but but database and interactions that are isolated from everything else so that they behave independently from the rest of the uh the application system and that that helps to find a microservice it's an architecture choice there's there's many things that you can do with it yeah i see alexander says it's it's an architecture choice you can build it using multiple apis absolutely and there's other there's other parts of an application you're going to want to layer around it security cueing how it interacts with other services how it deploys how it scales up and down it's it's more than just an api um hashir uh asks um can i have a session on using github copilot to create small non-trivial applications well github copilot doesn't doesn't write an application it's a tool that assists with writing software um i'll tell you what i have copilot installed on on the machine that we're going to be using today um i'll use it for a little bit of our session today so you can see um how it helps how it how it can sometimes get a little overwhelming and and i'll let you um make a decision on how best to use it with your application um getting ready to walk the dog while watching the stream says pc nerd well that's fun why are there less content tutorials on mvc5 but net.net core is everywhere all mvc5 content are old but not updated says das p um mvc5 honestly um the the move is to encourage folks to check out net core because it is that same mvc structure that same architecture but runs significantly faster and is available on every operating system so that's why because that's where the time and investment of the team is and you're going to get much much better um interaction and performance and and right the new capabilities that support the web are being delivered in asp.netcore.netcore.net 6 now so that's where you're going to see the interactions tgs asks what is my prospect for wcf wcf is uh no longer being innovated on it's available it's very stable it runs fantastic on windows you can build with net framework for eight and target wcf going forward though if you want to build stuff that is cross-platform that is that that runs on an open source framework that is uh built and supported and and is going to continue to receive innovation gotta get to net core i recommend you check out the grpc bindings for asp.net core at crem uh on youtube says the problem is i want to start with dot net six but when i get uh stuck there is no help because it's new version and the community is not that big completely disagree akram we have folks on on these channels broadcasting all week long all of our documentation all of our tutorials on the.net website have been updated and uh support.net six um and everything that you see that is.net 5 works on.net 6. so um definitely where i would i would suggest you go because take your technology because net six is a long-term support release we've we've put a ton of documentation around it and there is a um there's a lot of investment to ensure that it stays the fastest framework out there on youtube prosthg asks can map get route to a razor page no uh razer pages have their own routing defined at the top of the page um we haven't covered razer pages yet but you define that route by saying with an at page directive and you specify the route you want that razer page to listen to peter is here from hungary hello hello uh felipe says hi jeff have i done any tutorials on docker and kubernetes no on the old series you've said that you're going to cover that topic can't find it anywhere no i did not go into kubernetes um i made the decision that kubernetes is more architecture than it is um than it is development not architecture it's more operational architecture than it is a development tool in technology and quite frankly the documentation and support for kubernetes out there from everybody is dreadful it is terrible it is awful i would not recommend anybody go near it with a 10-foot pole because the cost for kubernetes scales out of control uncontrollably it is insane how bad kubernetes is for folks that want to manage a small application i wouldn't recommend you touch kubernetes unless you know it and you know it extremely well and you know what you're getting into because it is not easy to manage and get into it it literally it's a world of its own that is something that as a developer i don't want to know i don't want to know i don't want to touch it it it scares my wallet so um and that's my opinion other folks will will disagree with me that are experts on that that's fine they can they can have that opinion um but i i i've been faced with um unexpected hosting bills because of that and i i've spent enough time trying to learn kubernetes that i know it's something that i don't need um suraj on youtube uh asks when should i use blazer versus.net core mvc uh that's like choosing between pepsi and coke um use mvc when you when you want to use the mvc pattern you want to render things on the server and and take advantage of that use blazer when you want to try out and have that spa like application that you want to deploy and and run uh offline in in on a device that isn't connected occasionally connected uh but you can also use blazer server side and have that component based framework that is more more akin to web forms um mvc is very very much targeted towards folks that like the model view controller architecture so it's your choice um one punch mac on you on twitch asks are there any changes required to move.net core apis to azure web apps nope you can you can take a net core api and publish it to azure app service quickly and easily um literally there's a publish button in visual studio that'll generate github actions and send it out there for you um super viking on youtube how's it going there aztec consulting super viking uh asks can you secure a web api using a combination of api keys as well as identity and azure or do you have to choose one or the other i believe you can combine the two um but i i wouldn't mix and match that too much india on youtube say i would always use blazer versus old mvc that's the direction that i'm going these days so um ty's vdd on twitch asks what is the best way to find the community can i recommend a site where to find the community4.net 6. i'm not sure what you mean by find the community there there's discord servers for c sharp there's there's tech community out on uh dot.net if you go there um all kinds of places that you can stackoverflow has all kinds of folks talking about.net 6. i'm not sure what you're what you mean by the community um because there's lots of websites where folks are interacting with this so um sean on youtube asks is razer page is still the advised path over mvc for perhaps for apps that are suited three major apps still in dot-net framework for eight that will migrate trying to determine a future-proof solution as much as possible there is no such thing as a future proof solution in technology let's let's be clear how how future proof would you like to be web forms is still supported 20 years after it was invented is that future proof um mvc is is still supported and innovated on on.net framework 13 years after it was released it's been innovated on and migrated and now has the.net core and net.net six capability uh frameworks running underneath of it is razer pages advised it's i wouldn't say it's advised it's a choice that you can make if you want to build something that's page oriented instead of the model view controller oriented when you build a razor page it actually generates a controller for you that connects in and uses that cshtml razer page as the view it it literally is the same thing just they they cut out the one piece so you don't have to manage that kubernetes very much is a devops thing yes but a little bit it's a little bit overkill for most folks um let me see here scrolling scrolling um james foreman on youtube says kubernetes is for the enterprise team not so much for individual developers totally agree cloud engineering can be hard that's right profig das p uh you're very welcome for answering your questions i'm the only youtuber who answers all questions with so much information thank you do me a favor drop it i i love the comments like that um because quite frankly folks on on the the feedback that i get on youtube when when it runs through sentiment analysis is dreadfully negative not a fan of that at all um so i i really struggle with delivering content for youtube how am i so chipper on a monday morning asked richard on youtube that's what i do that's my job um um trying to decide if stick with mvc or doing conversion switch to razer watch the scott allen video before any kind of suggest razer um much respect to scott allen um our our late friend um who who innovated a lot of the training technology you see folks delivering on youtube on twitch on pluralsight um much much respect to scott i i always saw him as a mentor um as a leader for us as as trainers um as as folks that were delivering and answering and helping um i would say that that razor pages was a way that in scott's time razor pages was a way it was a was a thing that the team was innovating on and they were recommending folks check out it was never meant to be a replacement for mvc and we still continue to deliver both user interface technologies to this day and support them both it's all a question of of choice how do you want to build your application we want to give you that option to interact with those so that's the answer and that answers dukasoft there on twitch as well um you're a unix linux person at amd for high performance computing and cloud machine learning workloads two alpha three by two my goodness um i've got my ryzen 5900 ryzen 9 5900 over here um but i will tell you i have a geforce 3700 in there i don't have an ati card um but i am i am very much team red over here um i i honestly um i never really got into ati cards so um four minutes left on the ama here gonna run through these uh i'm sorry what is it i need help with the acronym there nick d-a-p-p-s what is that uh jens let's ask what's the best strategy for sharing business logic from a shared library in xamarin forms with a blazer project you want to share results generated in the app on a web server publish a nuget package share a project share a class library and reuse it in both places glasgow astro on twitch asks am i relieved i don't use log4j um i feel terrible for for those folks that were just maintaining an open source project not getting paid for it and now getting crucified by by organizations all over the world for for missing an issue and now going back and fixing it really says something about maintaining and supporting our open source projects out there that you depend on that you bet the enterprise on um costs nothing to throw these folks a couple bucks throw them a hundred bucks a month if you're depending on their technology if if you depend on a dozen different open source projects to as for your organization to drop those those folks 100 bucks a month each it's less it's pennies compared to how much it costs you to hire a developer and you're making their day you're making their month because they're getting a little bit of cash that's going to help fund and show that they're appreciated and can continue to build any chances of showing tailwind css instead of bootstrap uh no because tailwind is not currently what ships with asp.net core um that we might get into showing that when we get into asp.net core showing alternate frameworks but we're gonna prefer to show those frameworks that ship with asp.net um gonna hustle through here two and a half minutes to go if i start a new project for my customer try to use api or grpc uh grpc is just a flavor on top of api you're gonna do great with both andy walter on youtube says blazer is future proof blazer has been declared that we will support it for at least the next four years we're continuing to invest in it i wouldn't say that it's future proof i would say that there's a lot of investment going on there and you're gonna be covered for at least the next four to five years if if technology shifts significantly all things change arsalan asks why should i choose blazer over javascript um sorry that's that's a little bit too far off topic for less than two minutes to go i can't answer that question um but i will tell i will tell you i prefer blazer because just like folks use like like node for their javascript development so they have javascript front to back you can do the same thing with blazer and have c sharp front to back um yes there is a c-sharp discord you can check out distinguished moments any plans to have a demo with gpt-3 at any point gpt3 no i don't know what that is so no what front end do i use for what now zealous sorry need context uh digitaldummy says kubernetes is pretty fun if you're in stockholm uh what's my name dude moving on i would pick blazer if you're not familiar blah blah blah blah blah blah blah blah blah gregory white any chance of seeing taylor you already asked that question please don't repeat questions i read every uh every line of chat here um yes big love for scott allen out there how does the base href work in index html deployed your wasa map despite having a base in the base h graph it still goes to slash page um you got something else going on there friend what are my thoughts on python and fast api it's not as fast as asp.net core how about docker does net app need docker nope does docker affect net performance nope um dapper dapper i'm not touching on on azure dev we need to draw a line between these azure dapper data dapper azure dapper no not touching that because i'm not talking about dapper web30 web30 is a lie web30 is a scam where do you think that money's coming from do you really think people are paying thousand dollars six hundred thousand dollars for a sketch of an ape i mean honestly do do you really think people are paying that because they want a sketch of an ape this is folks moving money out of places where they can't convert their money to more um more uh valuable currency um all right excuse me um finishing up here we are at the end q8 that should say qa complete um yes i have a very strong opinion on web3 it web 3 is something that a bunch of uh venture capitalists in in silicon valley coined in an effort to scam and create their own coins that they're giving folks because they can't afford to actually pay people that's what i think of web3 um jquery is certainly future proof because there's still a lot of folks that use it today um one of my favorite blazer view control toolboxes syncfusion telerik devexpress absolutely love them all um i use the the telerik uh components in a project that i'm currently working on i'd love to check out the other components call me be happy to check them out um digital scarcity yeah and nfts are certainly a lie right click save as boom that six hundred thousand dollar drawing of an ape i now have somewhere else you're welcome for streaming this morning broken sword acts good to see you um mud blazer is a pretty cool set of components yes it is um yeah and folks that are saying oh we'll just issue more coins we'll just issue more of these sorry it's it that's not how these things work you're trying to hide your funds why oh and we're hiding them in public that doesn't work um asa blood no i'm not gonna do any advent of code on stream there's plenty of other folks that are doing advent of code and quite frankly i'll let them do that because i guess they don't have creativity to come up with their own projects their own tools and things that are interesting for folks to work on is node.js worth it to learn i don't think so no it's incredibly insecure um from i mean do file new project and start installing packages and you're gonna see high security warnings come through in an instant don't do it um are minimal apis more performant than classic controllers yes audit we're gonna get into that in just a minute well i wouldn't quite go there at broken sword but i i i will say that there are things that i do on stream there are things that i do as far as submitting and interacting with the tech community where i want to create space for other folks i want to allow other folks to develop their persona develop their speaking skills and um i don't need to to step on their code their content their technology we are gonna have f sharp on soon um i'm actually planning um a month of f sharp with our friend kathleen dollard more on that coming up i'll have more to share when we get into 2022. um so yes let's get into minimal apis and mudblazer one blazer is pretty cool i appreciate what they've done with that it is a lot of work to do some practical minimal apis yes let's do that so um moving on from the ama and and from what i'm seeing there yes i'm one of the only people that does this type of open ama and answers questions and and gives you exactly what i think of things um it's it's not easy to do and quite frankly it scares folks to the point where they they they pre-record everything i go live with all of this um oh that's fantastic broken sword thanks so much and dukasoft i'm i'm glad folks like the ama but let's get in let's talk about uh building building apis with asp.net core so that you get speed uh scalability durability and and the ability to document and roll those out and run anywhere you want asp net core seems like seems raw like node in express no no no no way till we see wait till you see we get in there um will we see an f-sharp version of asp.net core based on minimal apis no um can i show how to structure minimal apis a bit in a good way yeah i think we can do a little bit of that is this scott guthrie are you saying that because i've got the red shirt no um ama ama ask me anything is what ama is so i literally answer any question that's on topic for that first 40 minutes all right let me let's let's grab the things here let's get ready to go over to get ready to go over to the other set um and and start writing um some code start talking about minimal apis what it means how we can use them how they can grow how we can structure them i see some questions coming in here let's get that set up i am i gotta grab my phone while while i make the walk over here to the other uh to the other set and uh yeah let's get over to the other set uh here we go let's head over and i'll see you over there all right oh no i'm caught oh no get over there fritz get over to that other are you kidding are you kidding what just happened there um what happened to my restream chat there we go hey i'm over here now and um i've got my lighting needs just a little bit of help there one second one second just set that filter i think that's a little bit better that's probably a little bit better there we go all right i missed a couple questions there at the end um before before i cut over here you can still hear me well good good i'm i'm glad to hear that carl and i've uh i've got my teleprompter online here i can see everything all right and there you go there's the songs that are playing as we're going live with stream beats today from harris heller using the edm playlist oh all right so minimal code minimal apis with net will i be sharing the code i always do distinguished moments check it out you're on youtube if you're on youtube check out the link just below here you'll you'll see the link to all the code that we're writing i'm going to open up firefox over here and and jump in and show you exactly where everything is uh it is on github.com c sharp fritz c sharp with c sharp frets there you go it's right there um and today we are down under we are in sessions we are in season one and we are looking at 0 1 1 4 minimal and there's the same readme that i'm showing you on screen the code samples that we're going to go through are in these two folders here and any other code that we write any other tuning that we do here live on stream i will commit and upload into this repository so if you're watching the recording this might not look exactly the same what i'm showing on github with what you see when you navigate here i may have added some content i may have written a little bit more pros and added some links down here to help support a little bit of what we've learned maybe a little bit of what the chat room was discussing and suggesting we get into i may add to this and expand a little bit um please understand that the github repository is a live repository it's going to evolve and change and it might not be the same as what you're seeing right here today all right so um you like visual studio code but it is not full fully compatible with c sharp 10 says audic disagree and i will show you let me let me show you that to get things started right now let's do that so i still see a bunch of folks from youtube chiming in um folks on twitch you out there hello there we go i think we just went did we go no we didn't go around the horn all right so i'm actually in visual studio code here um and i'm going to start with the with a contact app let's build a simple contact application using i'm not going to go all the way to minimal apis yet but i want to take advantage of some of these initial features that are available to us in c sharp 10 that will help us to understand how we can interact with with data interact with some of these things before we start layering in asp.net core ah good there you are twitch friends so good to see you i saw a bunch of youtube in a row and and didn't see anything come through over there hey chris jones shawno and saint g85 fantastic good to see you been using coderish on twitch has been using minimal apis for a month and they're loving it so far terrific uh yes twitch is another streaming surface and we're over on twitch tv twitch.tv slash visual studio so there's tester coder with the heat guys and mode all right so i'm going to start building next to the the finished versions of these apps here um so let's do this let's uh let's clear and yeah so let's call this um let's call this my first app right no no fritz uh hang on that's bad idea let's create a new console application to start here my first app and this takes advantage of csharp10 and our new templates that are available in.net 6 to give you an application that is very small and has just those uh those lines of code that you need to get started building an application so i'm going to go back over here and you'll see there's my first app and it's got a project file here with some things to find and we'll talk about what those are in a minute and i've got a program cs that has just a very simple hello world okay um so let's get into uh i'm not gonna get into validation as part of this um but it's certainly something you can layer on easily uh let me add now i'll leave this where it is so i'm actually gonna build exactly the same content that's in the contact app project but we're going to do it live here and talk through this um so i have just a console.writeline that says hello world and that looks like some of the code we've been building in our notebooks um and consequently i can say dotnet run and it will compile and run that and i get a very simple hello world being output big deal but what's going on under the covers here is those that there are things that we didn't touch on we didn't need to cover when we were building and working with notebooks called using statements and namespaces using statements and namespaces are ways for us to keep our code organized so that we can have our objects laid out across all of our folders and and our our projects that we're going to be sharing in a way that that creates a little bit of nomenclature a little bit of structure that we can share and make available to folks in a way that makes sense and can grow and doesn't trample over other objects so you define a namespace to house the content of your classes and and enums and structs all of those things that you're creating you add using statements to indicate in your files well use the contents from this folder from this namespace i'm sorry scratch that you add using statements to declare use the contents from this namespace without having to include the namespace in working with my content so if i wanted to work with let's say a a string reader i could refer to it as system uh io well i said string reader string reader i can use that entire syntax right there and that gets a little right overwhelming to have to write system i o string reader everywhere so what we do is we shorten that get rid of the name space and we add a using statement and now it knows what string reader is so i can say string reader sr equals new string reader right without that using statement it gets a little confused what's a string reader um give me one second let's do that and it's going to get confused it doesn't know what that string reader is what do i where's that coming from right um and i'll run a quick build there just to show you that it throws the error this isn't in the project file that's why it's choking yes i know i know um my first app i'm not in the right folder now.net built that there it is see there's the error i don't know what this is so um go up one dotnet sln and my first app and now it should pick up what that is i'm even going to reload the window so i'm in visual studio code and it shouldn't know what that is now and i should get a little underline showing me hey that's a problem or brandon shouldn't be picking that up because i removed that thank you yes no uh fine come on there it is it doesn't know what these things are it's got this red underline because i don't know what that is i need a using statement to help tell it well here's where you find string reader or uh here's another one so we can find console so um and i i have the wrong syntax here for creating a new screen reader right um okay come here so right now i've got a compliant string reader and i'm off and running in.net 6 i showed previously we don't need these using statements because we have something called implicit usings and that's what i commented out over here and that generates a series of using statements that are made available inside of our project that simplify our code in files like this let me take a look at chat and get caught up here uh why am i not using visual studio uh because somebody said that uh they wanted to see me use visual studio code with c 10 and net six um is the image blurring it shouldn't oh my gosh why didn't what happened to my there we go the the camera is yes why is my camera focus going out here hello that's weird um that it's losing focus so bad i need to turn off auto focus it looks like all right um let me see what else is going what get those glasses in prescription yes you can these are from gunner and they do make it uh they do make uh prescription versions of these um we're not talking about f sharp today please stop going back to that um what versions of core were using.net 6 um yes and we're going to show global usings in just a minute um and and let's see it's not distance to camera i think it's focusing on my background a little bit um all right so we have these top level statements that we can write into our program cs file just like we had um inside of our notebooks we were able to write code directly at the top of our application we didn't have to write classes in order or structs or enums to to start working with our content we can do that now in our program cs we can have one file that has here's those first lines of code that you should execute when this application is started this means that we can um we can interact with we can interact with the command line request directly here before we hand off to all the object-oriented capabilities that we want from our classes structs and the like so let's let's introduce let's bring in yes i'm doing the link to csv demo so let me bring in um i'm gonna go into my first app and let me add the link to csv nuget package so i can create some some additional interesting capabilities here so i'm going to say net add package link to csv and this will download that new get package that will allow me to query a csv file with link statements so there it is it's downloaded and it's installed in my project there's the reference right there let me go back up here and i can now load and interact with that so i can create a context so i can say new link to csv dot csv context and i now have the ability to read and interact with um a csv file like comma separated value file think like a spreadsheet right an excel sh spreadsheet maybe a google doc that you saved in comma separated value csv format we can now read and interact with here directly yeah not seeing a class is strange padaro you're right um yes this is c sharp um how can somebody create their own link to csv why somebody's already created it i mean enhance it a little bit maybe but um is it just templates that hide the usings no you can still show it if you want you can still enable it those are implicit usings here if you remove that you're now required to add them you're now going to get errors that like that one that say well you need to declare these it's up to you if you want to enable or disable them using that statement right there implicit usings turn that on or off appropriately to interact with that yes we are going to get into ef core so i'm keeping an eye on the time here so i've declared and added uh this capability and uh yeah put implicit usings back on there it goes so now i can create a csv file on disk inside this folder so let's create a new file i will call this contacts csv and we can put some stuff in here um right so let's put name streaming service yeah let's just say name and streaming service um and i'm gonna say fritz uh twitch i'm gonna just roll off a couple names here there's johan on twitch who else is here i see obinna on uh youtube let me see who else do i see andy on youtube uh let me keep scrolling here um let me see um so meet on on youtube sure all right um that's good that's plenty to start here all right so i've got a little csv file and i want to load these in and interact with them in my application i can do that by creating now some sort of a contact class that i want to work with and i can read that content into that class and interact with it so let's create a public uh record class i'll call it contact and there were two fields name and streaming service so let's create those two fields as properties string and i have name and i'll create another one and it was streaming service and those properties i've defined to purposely match the headers on that contact file so that i can load and read those now there was a question about well how do you organize this stuff so it it becomes a little bit easier to manage well let's move that contact out into a folder here let's call it models and i'm going to take this contact object move it to its own file that would i did a control period there to jump into that and i'm going to go to move type to contact cs you can't see it it was behind me do that again ctrl dot there it is and i'm going to say move type to contact cs okay when i look over in my my my file explorer over here there's contact cs but i want it actually inside my models folder and there it is now when you have a class in a folder like this it's you want to put a namespace around that to reflect the organization that you have on disk so i can declare a namespace around this like this okay and typically the content inside that namespace is tabbed over now another one of those c sharp 10 features we learned about previously is file scoped namespaces this block wrapping the model is a little it's just why do i tab things over when there's only one namespace in this file so let's just make it right just a what we now call a file scope namespace so this is a dotnet6 feature that's available and now i have my contact it's in the models namespace that i can go and work with actually it should be my first app dot models okay so i'll go back to my program cs and i can now read things into that model's contact object using my link to csv here so i can say var contacts equals ctx read and i want to read them into my first app models contact right you see the little bit of organization that we have there and i'm reading that from contacts csv okay everything ironed out here and it's all clear no underlines so i'm going to read that content and just paint it on the screen now i made contact a record class so i could just put a tostring with it and just output that data so for each contact in contacts i'll just say console rightline contact okay now we can organize this a little bit i could turn this into a using statement here for these right and delete that namespace generate the using statement put that at the top of the file makes it a little bit easier to read i could do the same thing with link to csv right get rid of that and turn this into a using statement sure um and if we dotnet run it should go through our list of contacts and just output um there they are fritz johan obinna andy and sumit there we go and the services that they're connecting and watching on right now easy and and we we did a bit of this before we talked about c 10 and net six but let's level this up let's take this approach and let's put it into asp.net so we can interact with a contacts list that is now stored in a database we learned a little bit about entity framework core so let's use those techniques that technology to get data out of the database to put data into the database and deliver a very cool little api around that in just a couple lines of code here that uh will be something productive for folks to use let me take a look back at chat and catch up here um yes with source generators you can create classes automatically yes um we're not talking about that today you imagine the implicit usings are are still compiled down contains all the required dependencies behind the scenes um sean so to your question the impli the in the implied usings right right the implicit usings here actually get generated and are sitting over here inside of the ops folder if you ever need to take a look there they are my first app global using g for generated files and here's the usings that were generated for you because you turned on implicit usings so they're still there they're generated and sitting there on disk so that it knows how to refer to them and and what to um what to include appropriately there's a page in the docs in the in the c 10 docs that will show you what the implicit usings are for the different project types in.net um web apis can be consumed using http client yes and that's right implicit usings are quite frankly a compiler uh what if a comma happens within one of the entries asks bulat um if i you can using link to csv you can put double quotes around words and it will uh appropriately escape that quote for you that's why you prefer tab delimited not comma separated to each of the room um records in c sharp introduced in c sharp nine that's correct uh are immutable you are correct we're getting more and more functional stuff in c sharp you better believe it um english only please human world um positional records are immutable yes why need using for models and not for system because system was generated with one of my implicit usings and models is not thank you for asking that question i can make that go away by including a um i can i can generate a using here that is enforced across the project um and this is uh uh what was it my first app dot models yeah right i think i have that right i think i have that right do i have that right so now if i go back over here i should be able to comment that out try building that now i got it wrong um shoot it is is it global using i forget what there's a way to include a using statement in here um did i include it in no i didn't include included over here um i'm forgetting that syntax yeah using include i thought i had that right so i just need to put that down here and not in property group is that what i did wrong yeah there it is so put that using statement in here and now it applies across the entire application which also means i can put it into project build properties files and lay them out and it just gets enforced in all the project files i can also create a global using statement in some other file right um i like the idea of creating a file over here called usings and i can write my own global using uh my first app models and come here you i've got too many files going on i've lost myself and then i can comment that out ah come on it's so long it's hiding way over here but that builds properly with the global using statement so you can put that using statement wherever you'd like and in whatever file you'd like some folks like to see it in the project file so it's easy to pick up that it's all right there i like the idea of an underscore usings file because as an asp.net developer i'm used to an underscore imports file that contains my um it contains information about the razer templates i want to import csv to sql no not gonna quite go that far uh that's right obenna that would be a positional syntax for a person record class um console.line shows object that's right siraj because i created my contact as a record class so you could create just a record contact but now in c sharp 10 we have record structs and record contacts what are you doing to me here restream it just refreshed and i lost chat yeah i just lost chat on the teleprompter nice way to go um ah there we go how smart is the implicit using if two dependencies have similar namespace you'll get the same collision that you would if you had two using statements on top of each other in a file that had the same object in the same name space you'll get that collision where it yo that same collision error where it reports oh i don't know what to do with this all right um cool all right so we got this working in outputs and it shows us our contacts let's level this up now and bring in entity framework core and and start connecting that to a database and interacting with data for contact objects and see how that can grow and interact with um interact with our application interact with our our data and web visitors that interact that want to visit our website all right uh come on i think restream just took a powder on their chat didn't they yeah i'm getting nothing from restream nice um you find the yellow underlines and the properties restream here on my well my teleprompter has dobs try this again because i i want to be able to see you chat room and and keep up with what's going on over there yeah i've lost it over here can i am i able to get anywhere nice let me get reconnected here no one second this is going to be a pain hmm all right i'm gonna keep going even though i can't see chad um yes folks were saying what's with the yellow underlines it's telling me that this could be nullable um it's protecting me from running into nullability errors if did we get it did we get reconnected here come on this is weird try one more thing fun things that happen when you step away for a little bit and come back to your home studio like hey guess what nothing works yeah it's not even seeing my phone to connect nice come on there we go now i get chat back all right i missed a little bit of the last few last little bits there um so this is a nullability indicator it's telling you that this value could be null at some point um the nullability checks are defined right here you can turn that on and off if you don't like seeing that let's build our first api project here and get going with this yeah gremlins right so let's build let's add a minimal api project into this um when you look at the list of projects that are available we these are the most commonly used ones but it doesn't include that minimal api so if i say net new list so here's the asp.net projects these are the web projects that are support developing and building web applications http endpoints that you want to work with and empty is the one here that has the minimal api in it if you build the web api one it'll give you the classic way to build apis with controllers i'm always jumping out of focus it's got to be the camera with autofocus turned on um i thought it was being smart and turning on autofocus and it's misbehaving today nice nice um okay so let's go in let's build a minimal um api project here so i'm going to jump up and we'll say down here um and move it to the top frets come on now you know better dot net new web so it creates an empty project that's set up for apis and i'll call this my first api that should be dash 0.0 that's do that again because i spelled it poorly get started right there we go all right good back over this time let's open it with um with full visual studio 2022 um i'll put it in the solution file here first fritz uh dotnet sln add uh my first api good all right let's go to visual studio 2022 take a look at how this works over there now that i've shown that it does work in um net six and c sharp ten work here do not delete this stream nope we don't uh elvia lovia so this gets archived you'll see it on the uh youtube.com.net channel look for the playlist c sharp with c sharp frets and you'll find all of my videos in there so we're going to open a project solution and i'm going to go not in dev intersection we are in c dev c sharp with c sharp fritz sessions season one minimal here we are this machine's a little bit older and was patched for uh spectre and meltdown so runs a little bit slower when i'm running docker in the background spoiler alert so here's my first api right here i'm going to set that as the startup project still loading other things in the background there we go when we take a look at the program cs file here you're going to see that it looks kind of similar to what we had before to get started so i have a builder that's going to create a web application here this is how we get things started with an asp.net core with a web application is we create some sort of a web application and we're going to build it put all our configuration stuff into this builder thing we're going to say build that and here's our first api map a request when you try to get the root of this little web application to return hello world we got this little lambda statement here that we're going to go through execute whenever that is requested return hello world and run the application run the browser and it's just going to sit there and wait for interactions so let's start this and see what happens where'd my coffee go we need that coffee coffee is good and this is going to give us that very very basic very simple hello world instance with our api it's going to start up a browser for me here in the background there we go there we go and hello world big deal great we've got hello world um you build a proxy like legacy api for microsoft sql routing in 33 c lines of code that's fantastic that's very cool absolutely stay-at-home gamer on youtube asks any chance you can define a tag for the cs proj file like implicit usings and have a custom set of usings behind it or is the way to go for that using a underscore using cs file you can create a directory a build properties file that sits inside your solution and it will apply that build property to all of your projects we do something similar in the blazer workshop that's available so um i will show you what that looks like it's inside github.com c sharp fritz slash blazer workshop this is actually forked from the net presentations version but it's it's my version i like my version but you can go find the original version at see uh github.net presentations slash blazer workshop and there's this directory build properties file and you can certainly put those properties those using statements that you want to be in all of your projects in a file like this and it gets inherited and applied to all the projects in the solution so very cool stuff it's just based on that um i think it's dot props file name it loads those in um i forget if it's exactly the file name my ms build knowledge is is slipping here but update create one of these files put it at the root next to your solution file and you can put those using statements in here so everybody gets it thanks for the question let me see what else is going on here um padaro asks what's visualstudiobuiltwith.net we use dotnet to build visual studio um it's wpf uh there's a bunch of c plus in there but um are we gonna use entity framework with sql lite that's right patrick yes we are um scrolling um looking through the questions here looks more like node.js ricky yeah you're right looks a lot like node.js um looks like node with express let's let's dig in a little bit further here so i want to set up an entity framework context that allows me to write to a sql lite database and i want to create that same contact object and and stash it in that database so how do we go through and do those things i'm going to start by stopping my api here i'm going to right click and let's manage nuget packages and i'm going to add to this uh microsoft oh shoot just well it was right there entity framework core sqlite this one right here go ahead and put that one into the project yep it's gonna install a whole bunch of other dependencies yes i accept you can have my firstborn don't tell her that um there it is so now it's installed it's available in the uh there it is the little green check it's installed in the project so now i can use entity framework core to define a connection string to a database i can define what my contacts object looks like and start working through being able to interact with those things so let's start off creating that contact object again so public record class contact and i want um i want those properties so uh let's create a property for name there we go cool um string and i will once again have streaming service i need to put an id on here so we have a unique id for these things so i'll just create an id field there we go okay now once again i can start to organize these things and put that into a models folder let's not do that just yet because i want to create that database context so let's create my db public class my db context and this is a db context and yes we need to know what that is come on so i'm going to get a using statement for that fine and i want to create a collection of contacts that we're going to work with so let's create that collection i'll use my uh prop um what's it called i'm forgetting the feature name my prop shortcut to to drive into this real quick for entity framework core we want to define a collection of these objects it's a db set type db set of type contact and i will call this uh contacts okay now i have my my database context i do need to provide a constructor for this that is appropriate for and i forget exactly what the ah there we go i need a db context options so i need to receive um write a db context options class no of type my db context and i'll just call that options and i need to pass that into the base so that it knows how to build my database context okay great i've got these two classes set up so that it knows how to interact with the database now let's move these now let's put these into a models folder over here so i will add a new folder called models and let's push these out into their own files so we can work with them somewhere else and i'm just going to grab those two files and put them into the models folder yes now right i should be able to control dot on this there we go change namespace and it puts the namespace in it it wraps it with the old style block that's fine and if i go back over here to mydb context i can take this and change its namespace as well okay so it eliminated that extra namespace call we're good here on the construction and interaction of these so back over in my program um if i want to work with those objects i need a using statement for my models folder so my first fine right did i did i just call it models and not my first api models no i did uh yeah i don't have anything in this file yet okay so now we need to make that entity framework context available before we can start interacting with it i have 15 minutes to go here oh baby all right so when we want to make that entity framework context available for use across the rest of my application i need to put it inside of a service locator in the service locator for asp.net core is right here builder dot services and i'm going to add uh what is it add context add database contacts there it is and i'm going to specify the name of my contacts here which was write my db context but i do need to give it that configuration information that i'm using sqlite and the name of the database file that i want to write into so we're going to define that with a little bit of a lambda here and i'm going to say options dot um where is it use sql lite give me my i need a using statement for that and now i can give it a connection string to work with now i could pull that connection string out of configuration but i'm going to force it here because i'm creating just a little sample so i'm going to say data source equals contacts.db all right so i now have a sqlite database defined how to connect to it where to go get that data put a semi at the end of that and i can start working with that that entity framework context to build and interact with the database so let's get an instantiated version of that db context so that we can start working with the data inside the apis that i'm going to write down here so um let's create a context um actually i don't even need that yeah um now let's let's start here and work backwards uh app dots uh services i'm going to get service right yeah my db context there we go and now i'm going to say uh context database um ensure created so make sure that there's a database on disk that has all the things in it for me to interact with it um i believe i need to create the migration that goes with this so before i go too much further my first api dot net ef migrations and first so this is going to build make sure that we have that contact object and we're able to work with the database um you make me sad what did i mistake what did i mistake here any framework core does not exist uh yes it does uh yes it does it does it does it's right there says everything's there what am i missing are you kidding me just to make sure just to make sure no really go back over to the other project microsoft entity framework core sql lite there it is why isn't it restoring it for this project that succeeded try that migration ad again ah okay uh dotnet ad package that one so we can generate our content do it again oh wpf uh yeah it was used with wpf um why build apis in the old way when there's minimal api there's um folks like the organization of it and there's other capabilities to interact and um structure things a little bit cleaner so record classes are just like types in typescript yes i see lots of questions that came through i'm trying to keep up let me see here yeah i'm having a great day uh wyatt compiled one and not the other don't know don't know that's lots of fun there we go all right so i have my migration it's going to be able to generate and write the file so let's move on um yeah i know it might be null there so now i can do things like go get the list of contacts inside of that database and write it out when you navigate to the slash contacts location so i can map a get and say well let's let's when you go to slash contacts give me a my db context right and i can say easily here return contacts uh dot where is it contacts there we go uh yeah okay and i mean i could even really simplify that to right just right just that syntax right and now when i run this right you i made it very very clear exactly what we want it to do i'm gonna run this and uh what do you mean you cannot resolve it uh oh oh i didn't create a scope so uh app.services create scope dots come here you do it again entity framework objects are scoped in context they're available for the entire duration of a request so we need to get a scope in order to return things so there's my hello world and if i go to slash contacts i get no data because we didn't write any data into our database yet so i can start to level this up and add new features to it um and i've only got a few minutes left eight minutes left let me go to the completed version of the app and walk you through some of that code so you can see a little bit of what's going on here so just like we did before we have a database context let me come to these in a second so there's create scope get service and here we're setting up those mapped apis contacts for get interactions post because we want to add we want to create a new contact and we're we have this argument list that we're defining inside of this lambda here right it's just a signature for a method so i'm defining um here this is an asynchronous instance of one but i'm defining a database context and a contact that contact is being provided by some sort of a post interaction right it's in the body of that upload that's being added to this okay so that upload has that new contact as payload so i'm saying we'll just add it save changes and then return a appropriate created right a 201 statement that says i created it here's where you can find it at new contact dot id whatever that id number is for that contact i have a map get here that has this bit right here see that id int that is a routing parameter we're capturing the id as the next element of of the url string here of the folder uh path and it's going to be an id it's going to be an integer we're going to put it into the id field that's captured right there and we'll use that to do a find go find me a contact that has that key i have similar methods here for put and delete that will update and delete records appropriately i'll let you go through that source code it's in the project linked down below but i've also added open api into this i've added the uh swashbuckle project which gives me swagger here right so swagger this is the old name for open api it was called swagger so we have a contacts api and this is still got my dev intersection bit in here i'll just delete that and when i run this contacts api this has a slightly different contact structure but we'll take a look in and uh run this one instead so let's set this as the startup project and we'll run that and we'll be able to see a little bit of this all right so there's my hello world and if i go to slash contacts i get these contact records have a city field so i've got fritz and he's in philadelphia i've got scott and scott's from seattle but i've also got the ability to get just a single one of those if i type it correctly here i just want record one there it finds record one and presents that i have the swagger um api definitions all set up here for me so i can use open api i can generate a client if i want from this documentation and you see the location of it is sitting right here and i get this json file that has all the information about the api that's defined because i added those couple of elements inside of my minimal api and all of this content can be used to generate strongly typed clients that will be able to connect in and work with my little contacts api i've also got some great documentation here so i can add and change and work with content so if i want to add a new contact i can click try it out here and we can add somebody new um i don't know uh let me add let me add my friend javier and uh he's in des moines all right and execute that and it returns a message here that says that's what the curl looked like and javier is now this record id3 and it returns to me also a header that says you can find javier at slash contacts slash three so just to show that i can do that let's close that up here's that get that'll take in an id field so let's try that out an id parameter i'll ask for and there it is there's the curl request that it made that's the location that it went to there's the response that i got so we can do a lot here quickly with asp.net core building these apis and i've written it all in and this one has all of the entity framework and object in the same file but i wrote it all in 54 lines of code and i can add it to docker give this docker capabilities by right click add and i can choose i have it running right now i can't it's not in my dialog box there right click on that and say add docker support and it will generate a docker file for me so we can click through and you'll see it generates a docker file that looks like this i changed this slightly to give it the alpine base image to use but that means i can go over here and i can create and work with my contact api docker image and it's only a hundred meg so i wrote one c sharp file compiled it put it into a container it's a hundred meg it's ready to go ready to be deployed to use wherever you need it let me head back to the other uh desk out so we can wrap up all right all right all right back over here it is so good to be with you today chad we went through a ton there so quickly um but i hope i hope that that meant something i hope you you can go through and you can take a look at those samples i showed you where the link is to download um it is github.com uh oh crumbs go to the actual github and copy the location here before you paste it in chat let me go grab the complete url location it is right there i'll paste that into chat so you can take a look and and get involved with that i'm going to be around for uh on uh twitter if you have questions if you have questions drop them in the comment section below i i read those and answer them every every few days i make a pass through and and try and read and catch up on things um thank you so much everybody for tuning in i'll be back tomorrow hang on switch switch music here fritz um yeah there we go i'll be back tomorrow uh over on my channel over on twitch.tv c-sharp fritz um we've got a couple things we're doing here for thank miss for the the end of the year here um and uh it should be a good time hanging out with some of our friends from progress software and the code it live channel i will uh i will be back on thursday with a full day of coding over on my channel we'll be writing some blazer code working with azure and ravendb it promises to be a good time can i link that channel absolutely my channel that you'll find me on is twitch.tv slash c-sharp fritz those of you that are on youtube i hope you have a fantastic day take care um and those of you that are on twitch let me take a look around the horn here and see who we can raid who we can set up and get you connected with that's having some tech fun that would certainly be interesting to support um i think somebody that that um yeah somebody who's who we've raided before who's who's friendly to the stream here let's go and raid our friend tim beaudet um and support him thank you so much everybody for tuning in the this video like all the other videos in this series you can find over on the youtube archive youtube.com slash.net check out the playlists and look for learn c sharp with c sharp frets i really appreciate you tuning in i love our ama sessions together i'm going to be taking off from this stream for the next two weeks and i will see you again in january 2022 where we're going to pick up learning a little bit about asp.net core all right get ready to say hi to my friend tim over on twitch those of you on youtube have a fantastic day check out some of the other great videos we have here on youtube if you're on twitch get ready to say hi to our friend tim and i will catch you next time take care that's a little free
Info
Channel: dotNET
Views: 3,785
Rating: undefined out of 5
Keywords: minimal apis, c#, dotnet, .net, asp.net core, express
Id: beHedR-OAP4
Channel Id: undefined
Length: 121min 12sec (7272 seconds)
Published: Mon Dec 13 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.