static void Main(string[] args) { // Update using repository start IUow uow = new EfUow(); IRepository <Customer> repository = null; IRepository <Address> repAddress = null; repository.SetUow(uow); repAddress.SetUow(uow); repository.Add(new Customer() { }); // add inmemory repository.Save(); // final commit repAddress.Add(new Address()); repAddress.Save(); uow.Commit(); //uow.Rollback(); // Update using repository end //Customer customer = new Customer(); //customer.CustomerId = 1; //customer.CustomerCode = "C001"; //customer.CustomerName = "Mrinal"; //customer.Addresses.Add(new Address() {Id=1, Address1 = "delhi" }); //CustomerEfContext context = new CustomerEfContext(); //FLOWER : from > let > ORDER By > WHERE > // way linq query is written // updating // here i get customer by linq //var cust = (from x in context.Customers // where x.CustomerId == 1 // select x).ToList<Customer>()[0]; //cust.CustomerName = "aaa"; //context.SaveChanges(); //context.Database.EnsureCreated(); // this line ensures the database and table created automatically. ////context.Database.ExecuteSqlCommand("select * from tblcustomer") // execute raw sql //context.Add(customer); // Adds in inmemory //context.SaveChanges(); // physical commit }
public override void SetUow(IUow uow) { this.uow = (EfUow)uow; }