public void can_commit_multiple_db_operations() { var customer = new Customer { FirstName = "John", LastName = "Doe" }; var salesPerson = new SalesPerson { FirstName = "Jane", LastName = "Doe", SalesQuota = 2000 }; using (var scope = new UnitOfWorkScope()) { new EFRepository<Customer>().Add(customer); new EFRepository<SalesPerson>().Add(salesPerson); scope.Commit(); } using (var ordersTestData = new EFTestData(OrdersContextProvider())) using (var hrTestData = new EFTestData(HRContextProvider())) { Customer savedCustomer = null; SalesPerson savedSalesPerson = null; ordersTestData.Batch(action => savedCustomer = action.GetCustomerById(customer.CustomerID)); hrTestData.Batch(action => savedSalesPerson = action.GetSalesPersonById(salesPerson.Id)); Assert.That(savedCustomer, Is.Not.Null); Assert.That(savedSalesPerson, Is.Not.Null); Assert.That(savedCustomer.CustomerID, Is.EqualTo(customer.CustomerID)); Assert.That(savedSalesPerson.Id, Is.EqualTo(salesPerson.Id)); } }
/// <summary> /// Deprecated Method for adding a new object to the SalesPersons EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSalesPersons(SalesPerson salesPerson) { base.AddObject("SalesPersons", salesPerson); }
/// <summary> /// Create a new SalesPerson object. /// </summary> /// <param name="id">Initial value of the Id property.</param> public static SalesPerson CreateSalesPerson(global::System.Int32 id) { SalesPerson salesPerson = new SalesPerson(); salesPerson.Id = id; return salesPerson; }
public SalesPerson CreateSalesPerson() { var salesPerson = new SalesPerson { FirstName = "Jone" + RandomString(), LastName = "Do" + RandomString(), SalesQuota = 1000 }; _generator.Context<HREntities>().AddToSalesPersons(salesPerson); return salesPerson; }