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?
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...
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?
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
is working on a reply...