I am learning Petshop3.x, and some of them will be written out. PetShop3.x is clearly clear, respectively, the UI, Business Layer, Data Access Layer, typical N-layer architecture. It is very good. But Take a closer look, it is not so simple, the reason is that when Data Access Layer, I made some easeless architectures, that is, the factory model. So in order to make it out, I specialize in one Functional research, other functions are basically the same, Datong Small. I selected this. First, a picture: You can see that Petshop.Web Catagory calls the PRODUCT in the BLL layer, the code is as follows: Catagory.aspx.cs Find // Check to See eti the the contents are in the data cache if (cache [categoryKey]! = null) {// if the data is already cached, then used the cached copy products.datasource = IList) Cache [categoryKey];} else {// If the data is not cached, then create a new products object and request the data Product product = new Product (); IList productsByCategory = product.GetProductsByCategory (categoryKey); // Store the results of the call in the Cache and set the time out to 12 hours Cache.Add (categoryKey, productsByCategory, null, DateTime.Now.AddHours (12), Cache.NoSlidingExpiration, CacheItemPriority.High, null); products.DataSource = PRODUCTSBYCATEGORY;} and Petshop.bll.pro How does DUCT getProductSBycategory handle? Take a look at the following code public ilist getproductsbycategory (String category) {
// Return null if the string is empty if (category.trim () == String.empty) Return NULL;
// Get An Instance of the Product Dal Using The Dalfactory iProduct Dal = Petshop.dalFactory.Product.create ();
// Run A Search Against The Data Store Return Dal.getProductSbycategory (Category);} The top is actually the current code. We will find that the PetShop.dalFactory is the factory mode. CREATE has an instance of an iProduct. In fact, this is actually this When it created from PetShop.sqlserverdal, it was called a PetShop.sqlServerdal.Product.GetProductBycatagory method, not Petshop.OracleDal.Product.GetProductBycatagory. About this will discuss it. Say it, I think I am His call is familiar with it.