.NET 7 Update: Nullable Models in MVC in 10 Minutes or Less
Vložit
- čas přidán 13. 11. 2022
- In .NET 7, we can now have nullable page models and view models in Razor Pages and MVC. Let's see it in action in this 10-Minute Training video.
Full Training Courses: IAmTimCorey.com
Source Code: leadmagnets.app/?Resource=Nul...
Hello Tim, have you thought of making a video showing how to structure your project according to DDD? Or do you already have any courses that illustrate that? Thanks for all the tutorials, you're a huge help!
I love these 10 minute knowledge nuggets that are easy to mentally digest. Especially when you are old enough to have driven themselves to see Star Wars in the theatre. 🤣
I'm glad it was helpful.
This feature will be helpful moving forward. Thanks for the info :)
You are welcome.
THNX short but useful video
You are welcome.
Thanks for the great content Tim! I have a question about your courses. Is it possible to get the certificate of a course from the monthly pass or do I need to buy the course itself? Also do all of your courses provide a certificate?
All of the courses provide a certificate of completion, regardless of whether you purchase them or take them through the All Access Pass.
Thanks for sharing important information
You are welcome.
Ok. So if the list item count is 0, i can get pretty much the same results. I don't know a specific usecase for this where it would really help. I wonder if is it valid for API models?
Like if API model is null, are all child properties nullable or what?
A list with 0 items in it isn't the same thing as a null list. One indicates there were no records. The other indicates nothing was done. For example, if I said "give me a list of all employees with the last name of Corey" and it returned an empty list (0 entries), that means there were no employees with the last name of Corey. If it returned null, it means something else (it didn't do the lookup, there was an error looking up the results, the lookup isn't complete, etc.)
Hi Tim, which keyboard do you use while recording your videos? The keys are very quiet.
The Logitech MX Keys: amzn.to/3hzsfac
I personally recommend it as the best keyboard I've ever used. They are short-throw keys, which isn't for everyone, but I put MILES on my keyboard and it just keeps working. It also can connect to up to three computers via dongle or Bluetooth. I use it for both my work computer and my gaming computer as well as on my iPad. Switching between the three is a matter of clicking one button.
@@IAmTimCorey Logitech products are amazing. I also heard good reviews about their MX Master 3 mouse. But I use a ten-key less mechanical keyboard. It has blue switches and it's very noisy. Do you think that MX will be a good replacement for a mechanical keyboard?
I use the MX Master 3 every day as my primary mouse. As for the MX Keys being a good replacement for a mechanical keyboard, they are two different categories. If you are ok switching to a non-mechanical keyboard then yes, it is a great replacement.
@@IAmTimCorey Thanks for your replies. Much appreciated.
I don't imagine I will ever use this feature. For the types of things I develop, one of my core design principles is that each page have it's own page model that contains all the ancillary data needed to build the page (for things such as dropdown lists, etc) as well as a data model that contains the data used to populate the form elements (for instance, the data for which dropdown list item is selected). I never, ever want my page model to be null. I would much rather have a page model with an ID property that has a value of null, or better 0, to indicate a fresh form/element.
It all depends on your circumstances. It isn't a commonly needed item, but it is useful to have in place for when you do need it.
Yeah this is my approach too, every page gets its own model that bundles all of the pages data, including models for partial pages. I’m always passing something to the view,
Tim maybe you can do video about GRAPHQL we need this
Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/
What's the benefits of using null instead of empty list?
an empty list you can get the counts while you cant do it in null
Null and empty are different concepts. Empty means no records (select * from people where lastName = Corey and it returns 0 records). Null means one of many things in this scenario - the query was not run, the query failed, the results haven't been returned yet (a common one), etc.