static void Main(string[] args) { //Here we are creating the actual object MyDbContext MyDbContext ctx1 = new MyDbContext(connectionString); //Here is where we pass it to our first repository using (IRepository repo = new TestDb1Repository(ctx1)) { //Here we add 1000 customers to TestDb1 //bool IsSuccess = Add1000Customers(repo); //We have to save our changes to our database //repo.SaveChanges(); //Deleting customers with Id's 4, 7, 9 and 11 from database // IsSuccess = DeleteCustomersFromDatabase(repo, new List<int> { 4, 7, 8, 9, 11 }); //repo.SaveChanges(); //Get a list of addresses for the customer //List<Address> addresses = GetAddresses(repo, 20); //Console.WriteLine(IsSuccess); //addresses.ForEach(a => Console.WriteLine(a)); //Console.ReadKey(); } //Here we make our second repository connected to a different db //with a different context. connectionString = ConfigurationManager.ConnectionStrings["TestDb2"].ToString(); AdoNetContext ctx2 = new AdoNetContext(connectionString); using (IRepository repo = new TestDb2Repository(ctx2)) { //Here we add 1000 students to TestDb1 bool IsSuccess = Add1000Customers(repo); //Deleting Students with Id's 4, 7, 9 and 11 from database IsSuccess = DeleteCustomersFromDatabase(repo, new List <int> { 4, 7, 8, 9, 11 }); Console.ReadKey(); } }
static void Main(string[] args) { ConfigurationManager MyDbContext context = new MyDbContext(); IRepository repo = new TestDb1Repository(context); }