Esempio n. 1
0
        public void TestDbCtxGetOrAttach()
        {
            //int id = LinqTests.customerIdWithManyAddresses;
            //var addresses = LinqTests.AwDal.List(db => db.QueryCustomerAddressesByCustomerID(id));
            //Assert.IsTrue(2 == addresses.Count);

            //LinqTests.AwDal.Invoke(db => db.ToStringEx(""));

            Customer cust = LinqTests.AwDal.Invoke(db => db.GetOrAttach(OrhpanCust, c => c.CustomerID));
            Assert.IsNull(cust.EmailAddress);

            Customer cust2;
            using(var dbc = new AdventureWorksLT2008R2Entities())
            {
                dbc.Configuration.LazyLoadingEnabled = false;

                cust = dbc.GetProxy(LinqTests.TestAspects).Single(db => db.QueryCustomerByID(LinqTests.CustomerIdWithManyAddresses));
                cust2 = dbc.GetProxy(LinqTests.TestAspects).Invoke(db => db.GetOrAttach(OrhpanCust));
            }
            Assert.IsNotNull(cust2.EmailAddress);
            Assert.IsTrue(cust.Equals(cust2));
        }
Esempio n. 2
0
        public void CallPerfDbContextAugmented()
        {
            long runsPerSec;

            using(var db = new AdventureWorksLT2008R2Entities())
            {
                db.Configuration.LazyLoadingEnabled = false;

                runsPerSec = RunCounter.SpinPerSec(MillisecToRun, () =>
                    db.GetProxy().List(inst => inst.QueryCustomerAddressesByCustomerID(customerIdWithManyAddresses))
                    );
            }
            this.TestContext.WriteLine("db.QueryCustomerAddressesByCustomerID(customerIdWithManyAddresses) augmented sequential base line test result: {0} calls/second.", runsPerSec);
        }