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. Excellent delivery Outstanding justifications. Continue the excellent work..YY토토사이트

  2. Thank you for sharing your opinions. In my opinion, the website’s administrator put a lot of effort into maintaining it..YY토토사이트

  3. Maintain the good work guys I’ve included you guys to my blogroll. Continue publishing such information on your website..YY 슬롯사이트

  4. i have to say this thing you have did good and nice
    무료 카지노사이트

  5. very good part, I want to tweet this to my followers.
    카지노사이트

  6. I feel rather privileged to have discovered the website page and look forward to some more pleasurable times reading here. 바카라사이트 추천

  7. Your submission is enormously beneficial to get some effective tips to lessen weight appropriately. You have shared considered one of a type quality pictures of the equal. 토토사이트 순위

  8. Wow, that’s really unexpected information I’m looking forward to the next one 슬롯사이트 순위

  9. Wonderful illustrated information. I thank you about that. No doubt it will be very useful for my future projects. Would like to see some other posts on the same subject 무료 카지노사이트

  10. Nice site you got here, very awesome and good content.

  11. kazehaya's avatar kazehaya says:

    Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot! https://www.outlookindia.com/xhub/e-gaming/%EC%B9%B4%EC%A7%80%EB%85%B8%EC%82%AC%EC%9D%B4%ED%8A%B8-%EC%B6%94%EC%B2%9C-best15

  12. Wonderful, what a web site it is! This web site presents
    useful information to us, keep it up.

  13. Heatherjane's avatar Heatherjane says:

    I read your article very impressively I want to write something like this

  14. Carolynmary's avatar Carolynmary says:

    It’s really pleasure to read your post. Thank you so much for writing such a nice post

  15. Meganroger's avatar Meganroger says:

    thanks for sharing great blog article thanks again

  16. SorayaFrench's avatar SorayaFrench says:

    Nice Blog. Thanks for sharing with us. Such amazing information.

  17. Buy OnlyFans Creator Account

  18. You really amazed me with your writing talent.
    안전놀이터

  19. Hard to ignore such an amazing article like this.

    메이저사이트

Leave a Reply

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