Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sam 1 post 81 karma points
    Mar 12, 2024 @ 08:05
    Sam
    0

    Query from Custom Database Table

    I have a table that contains date of births of people. I want to make a query that checks the table for people with birthdays on today's date and display all of them on my homepage. Any help on how I would achieve that?

  • Marc Goodson 2141 posts 14344 karma points MVP 8x c-trib
    Mar 13, 2024 @ 16:50
    Marc Goodson
    100

    Hi Sam

    Have a look at this article about working with custom tables in Umbraco.

    https://docs.umbraco.com/umbraco-cms/tutorials/getting-started-with-entity-framework-core#introduction

    Although it starts off by showing how to create a custom table and you already have yours it does go on to have an example of how to inject the entity framework database context in order to query the DB.

    Depending on how your site is implemented you'll either want to achieve this inside a ViewComponent, rendering the results along with the rest of the page or if your site loads everything asynchronously, then maybe you'd do the look up to the database inside an API Controller, so it can be called from javascript...

    Regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft