I'm having issues executing a stored procedure that does not return any data. I created a custom repository, but the dbcontext is always null and I'm not sure why.
I read this thread but it doesn't show interaction with the dbcontext: #3345@0db48d15-e4b1-451c-a96b-5b92e3a173c1
Attached is my custom repository and the error that i'm getting. How can I execute a stored procedure?
2 Answer(s)
-
0
Nevermind - I figured it out. For anyone else that comes across this, this is what my custom repository looks like in order to get access to the DbContext:
public class PMRenderLeaseAgreementRepository : PropertyMentsRepositoryBase<PMRenderLeaseAgreement>, IPMRenderLeaseAgreementRepository { public PMRenderLeaseAgreementRepository(IDbContextProvider<PropertyMentsDbContext> dbContextProvider) : base(dbContextProvider) { } public void ExecuteStoredProcedure(string query, params object[] parameters) { Context.Database.ExecuteSqlCommand(query, parameters); } }
Also, follow the ABP documentation to put the interface in the .Core project so you can inject it in any of the services. I put the repository class in the EntityFrameworkCore project.
-
0
Thanks for the feedback @mikemey01 :)