Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to access Repository directly from Controller. #6408


User avatar
0
aggarwal created

Hi,

I want to simply the design for some of my controllers and use the Repository directly from controller.

Is there an example snippet anyone can provide?

Many thanks in advance.

Best Regards, Vikas


7 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    Inject it, like anywhere else.

    https://aspnetboilerplate.com/Pages/Documents/Dependency-Injection

  • User Avatar
    0
    aggarwal created

    Thanks @aaron.

    I was able to make it work.

    Does the Application Service expose the services as API? Coding directly in contoller would mean no api for that operation?

    Regads, Vikas

  • User Avatar
    0
    aaron created
    Support Team

    What do you mean no API?

  • User Avatar
    0
    aggarwal created

    @aaron: What I mean is that any methods that as written as ApplicationService in Projectname.Application project seems to be available as an API.

    If any database operation methods are written elsewhere, they won't be availabe as API?

    Just want to verify my understanding.

  • User Avatar
    0
    aaron created
    Support Team

    Application Service and Controller methods expose HTTP API, if that's what you mean.

  • User Avatar
    0
    aggarwal created

    Thank you.

  • User Avatar
    0
    aggarwal created

    Closing ticket