David Bowie

David Bowie

  • NA
  • 31
  • 415

Function within Model [.NET Core 3.1 web application]

Jul 1 2020 9:25 PM
Hello, 
 
I am new to C# and .NET CORE. My task is to write a globally accessible function that has no parameters and returns a calculated integer value from SQL database. In ideal world I would like to be able to retrieve this value by referring to it in the format of Sales.GetTotal() from within any controller. In my case Sales is the model name and GetTotal() is a function within the Sales model that sends a call to database server and retrieves calculated total. How is this achieved? 
 
I am writing a .NET Core 3.1 web application.
 
Thank you in advance for the pointers. 

Answers (1)