I want to get Data From IRepository in Standalone class like
//Standalone class public class Utility {
public string getdata() { Irepository<sampleCORE> testdata;
testdata.gelall(); } }
Use Of utility class Utility Utl = new Utility (); utl.getdata();
I used your Functionality Like pass iRepository in constructor. but in this case utility class is standalone class hence whenever i create object of that class it needs to be passed all declared constructor.
how can i get data without passing constructor of Repository.
I Used object of DBcontext of ABPDbContext Db = new ABPDbContext(); in this case i am not able to fetch data from datatabe which has tenantID;
1 Answer(s)
-
0
Hi,
If you want to use Repository to get data, you need to create it with dependency injecytion, so the class which contains it must be created with DI as well.
Also, if you want to use Repository, you should not create DbContext by yourself. You can read below documents for more information. <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Repositories">https://aspnetboilerplate.com/Pages/Doc ... positories</a> <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Unit-Of-Work">https://aspnetboilerplate.com/Pages/Doc ... it-Of-Work</a>
Thanks.