locked
Global Static Dictionary Initialization from Database in Webapi RRS feed

  • Question

  • User715841376 posted

    I want to Initialize a global Dictionary from Database in my web Api. Do i need to inject my DBContext in Global.Asax or Owin Startup. Any example would be much appreciated.

    Friday, August 14, 2015 6:28 AM

Answers

  • User1644755831 posted

    Hello internetbeans,

    I want to Initialize a global Dictionary from Database in my web Api. Do i need to inject my DBContext in Global.Asax or Owin Startup. Any example would be much appreciated.

    Since you do want to get data from the database you will need to connect to it on Application Startup event in global.aspx page when Application is started. You can create Repository (don't need to actually include the dbcontext it self in the project it may be in another project) which will handle the calling of the db and initializing static dictionary.

    With Regards,

    Krunal Parekh

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 17, 2015 4:43 AM