public void EFTest1()
        {
            var db     = new AdventureWorksDB();
            var stores = db.Sales_Stores.ToList();

            Assert.That(stores.Count > 1);

            // Direct Load
            var store = stores.First();

            Assert.That(store.BusinessEntityId > 0);
            Assert.That(store.Test() == "Concrete Class");

            // Parent Lazy Load
            var person = store.Sales_SalesPerson;

            Assert.That(person != null);
            Assert.That(person.Test() == "Concrete Class");
            Assert.That(person.BusinessEntityId > 0);

            // Direct Load
            person = db.Sales_SalesPersons.Single(x => x.BusinessEntityId == person.BusinessEntityId); // fetch again from db
            Assert.That(person.BusinessEntityId > 0);
            Assert.That(person.Test() == "Concrete Class");

            // Child Lazy Load
            var childs = person.Sales_Stores.ToList();

            Assert.That(childs.Count > 0);
            Assert.That(childs.First().Test() == "Concrete Class");
        }
Esempio n. 2
0
        public ActionResult GetPagingProductList(int nowPage, int perPage)
        {
            var adventureWorksDB = new AdventureWorksDB();
            var data             = adventureWorksDB.Product.Skip(nowPage * perPage).Take(perPage);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public FileContentResult GetProductImage(int id)
        {
            var adventureWorksDB = new AdventureWorksDB();
            var willReturn       = adventureWorksDB.Product.Single(x => x.ProductID == id);

            return(File(willReturn.ThumbNailPhoto.ToArray(), "image/gif"));
        }
        public void DapperTest1()
        {
            using (var cn = AdventureWorksDB.CreateConnection())
            {
                var stores = cn.Query <Sales_Store>("SELECT * FROM [Sales].[Store]");
                Assert.That(stores.Count() > 1);

                // Direct Load
                var store = stores.First();
                Assert.That(store.BusinessEntityId > 0);

                // Dapper doesn't have Lazy Loading
                var person = store.Sales_SalesPerson;
                Assert.That(person == null);
            }
        }
Esempio n. 5
0
        public ActionResult GetTotalProductCount()
        {
            var adventureWorksDB = new AdventureWorksDB();

            return(Content(adventureWorksDB.Product.Count().ToString()));
        }
Esempio n. 6
0
        public ActionResult GetProductList()
        {
            var adventureWorksDB = new AdventureWorksDB();

            return(Json(adventureWorksDB.Product, JsonRequestBehavior.AllowGet));
        }