dbContext

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
I'm new for nopCommerce.
I want to extend PriceCalculationService and for a lot of reasons I must use dbContext to call directly a TVF Function.
I have already added ref to CodeFirstStoreFunctions (https://github.com/moozzyk/CodeFirstFunctions) and done some modify to OnModelCreating (NopObjectContext).
Now question is:
how can I call dbContext from PriceCalculationService / GetFinalPrice to call my TVF function ?
Thanks in advance for response.
6 years ago
you can use below code

add new global variable on pricecalcualtion service.


private readonly IDBContext _dbContext;

//add to construcure
public constructurename(IDBContext dbcontext)
{
_dbContext=dbcontext;
}



then use the _dbContext wherever you wanted to use.
6 years ago
Thanks very lot.

Not being very prepared about "Dependency Injection" and "Inversion of Control" I could not understand this solution before.
Now all work fine.
Regards
6 years ago
nopNovice2 wrote:
Thanks very lot.

Not being very prepared about "Dependency Injection" and "Inversion of Control" I could not understand this solution before.
Now all work fine.
Regards


Ok I Understand ,no one is 100%  

Thanks :)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.