APIs in .NET – Part 2 – The Database

As noted in part 1 of this series, I will be building an application specifically to explore building APIs. To get started, I’ll want to build a back-end database. The application we’ll be simulating is a car dealership. Customers can list a car for sale, or look through cars they might buy.

We want to keep things very simple, so we will create a single table for now: Car

Car will have six columns

  • id (int primary key)
  • make (varchar 50)
  • model (varchar 50)
  • model_year (int)
  • price (decimal)
  • deleted (int)

By marking id as primary key you ensure two things: no two cars will have the same id, and each added row will have an incremented value. The deleted column allows us to have “soft” deletes — that is, we mark a row deleted but do not remove it from the table.

We can now insert a few rows:

insert into car
(make, model, model_year, price, deleted)
values ('Subaru', 'Imprezza', 2024 ,35500, 0),
('Subaru','Outback',2024,42000, 0),
('Prius','C',2022,25000, 0)

Note: I highly recommend the book SQL Pocket Guide (O’Reilly, Alice Zhao) for looking up how to do all the SQL operations I’ll show in these blog entries.

With this table, we can create endpoints for the CRUD (Create Read Update Delete) operations and more (e.g., obtaining a list of available vehicles).

In the next post, we’ll build our first endpoint to get a list of available cars.

Unknown's avatar

About Jesse Liberty

** Note ** Jesse is currently looking for a new position. You can learn more about him at https://jesseliberty.bio Thank you. Jesse Liberty has three decades of experience writing and delivering software projects and is the author of 2 dozen books and a couple dozen online courses. His latest book, Building APIs with .NET, is now available wherever you buy your books. Liberty was a Team Lead and Senior Software Engineer for various corporations, a Senior Technical Evangelist for Microsoft, a Distinguished Software Engineer for AT&T, a VP for Information Services for Citibank and a Software Architect for PBS. He is a 13 year Microsoft MVP.
This entry was posted in API, Essentials. Bookmark the permalink.

358 Responses to APIs in .NET – Part 2 – The Database

  1. ljubiti se's avatar ljubiti se says:

    vykřiknout a říct, že mě opravdu baví číst vaše příspěvky na blogu.

  2. الاستمرار في توجيه الآخرين.|Ahoj, věřím, že je to vynikající blog. Narazil jsem na něj;

  3. Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.

  4. |Hello to all, for the reason that I am actually keen of

  5. I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.

  6. reading this weblog’s post to be updated daily.

  7. gruppe? Der er mange mennesker, som jeg tror virkelig ville

  8. مرحبًا، أعتقد أن هذه مدونة ممتازة. لقد عثرت عليها بالصدفة ;

  9. This design is incredible! You definitely know how to keep a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Fantastic job. I really loved what you had to say, and more than that, how you presented it. Too cool!

  10. 슬롯추천's avatar 슬롯추천 says:

    Keep on working, great job!

  11. Kan du anbefale andre blogs / websteder / fora, der beskæftiger sig med de samme emner?

  12. Thank you, your article surprised me, there is such an excellent point of view. Thank you for sharing, I learned a lot. https://accounts.binance.com/kz/register-person?ref=DB40ITMB

  13. It contains fastidious material.|I think the admin of this website is actually working hard in favor of his site,

  14. magnificent issues altogether, you simply received a new reader.What would you recommend about your submit that you just made some days in the past?Any certain?

  15. Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

  16. The blogs you produce are really of good quality. I love to read your writings and shall come again to check out the latest posts. 카지노사이트 추천

  17. You have done a great job. I will definitely dig it and personally recommend to my friends. I am confident they will be benefited from this site. Feel free to visit my website, thank you!토토사이트

  18. I was reading some of your content on this website and I conceive this internet site is really informative ! Keep on putting up. Feel free to visit my website, thank you!
    파워볼사이트

  19. Yeah! This is very interesting post. I look forward for seeking more on your website. Feel free to visit my website, thank you!파워볼사이트

  20. Captivating post. I Have Been contemplating about this issue, so an obligation of appreciation is all together to post. Completely cool post.It ‘s greatly extraordinarily OK and Useful post. Feel free to visit my website, thank you!
    파워볼사이트

  21. Your work is great, and I appreciate it. I look forward to reading more useful blogs from you. Thank you for providing us with such valuable information. Feel free to visit my website, thank you!신용카드현금화

  22. Excellent item. Very interesting over study. I actually adulate toward study this a polite portion. Thanks! maintenance rocking. 안전놀이터

  23. Thank you for posting such a great article! I found your website perfect for my needs. Feel free to visit my website, thank you!카지노사이트

Leave a Reply

Your email address will not be published. Required fields are marked *