protected Inventory GetInventory(string itemId) { var inventory = new Inventory(); using( var context = new PetShopDataContext()) { inventory = context.Inventory.GetByKey(itemId); inventory.Detach(); } return inventory; }
public void CreateInventory() { Stopwatch watch = Stopwatch.StartNew(); var inventory = new Inventory(); inventory.ItemId = ID; inventory.Qty = 10; try { using (var context = new PetShopDataContext()) { context.Inventory.InsertOnSubmit(inventory); context.SubmitChanges(); } } catch (Exception ex) { Assert.Fail(ex.Message); } Assert.IsTrue(true); Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds); }