Base solution for your next web application
Open Closed

Custom Repository #1093


User avatar
0
thomas kristensen created

Hi

I am trying to create a custom repository, which will contain all communication with DB stored procedures. However I cannot find any complete documentation on how to do this. My problem right now is how do I use a custom repository from the application layer?

I already read all documentation on the subject, but it is still not clear to me how to use a custom repository, when it has been created?


2 Answer(s)
  • User Avatar
    0
    theedge created

    Hi Thomas,

    So I assume you have got your application service that has in its constructor something as follows:

    public class BlogPostService : AppServiceBase, IBlogPostService
        {
            private readonly IBlogPostRepository _Repository;
    
            public BlogPostService(IBlogPostRepository aRepository)
            {
                //Save params supplied
                _Repository = aRepository;
            }
        }
    

    And your IBlogPostRepository has a method in it that will ultimately call a stored procedure? The trick is that when in the method for your repository, you can access the Context property which ultimately points off your DbContext class. And hanging off there is where you would have a method implementing your stored procedure.

    For s similair implementation have a look at #446

  • User Avatar
    0
    hikalkan created
    Support Team

    Just inject into your application service and call it's methods. What is problem on that?