The previous array of "Pro asp.net 2.0 E-Commerce in c#2005" edited a business system website, want to sum up the learned knowledge.
The site features a general business website
Here, let's talk about his frame.
Data Access Layer
Using the stored procedure to manipulate the storage of the database, there is a Shop.dataaccess class library dedicated (note that I'm here to change the original namespace to shop)
The class library uses a component to encapsulate operations on the database for Microsoft Data Access Application Block, which is simply copying SQLHelper.cs to the class, which automatically manages the connection, parameters, and names of stored procedures.
The Dataaccessbase class under the class library is a base class that almost all classes inherit, with two attributes, one stored procedure, and the connection string that returns the database.
Note: This is a string from the Web.config file that connects to the database, but cannot be referenced to the Configuration class in the class, so we want to add the additional reference System.Configuration.dll assembly
The following are the referenced contents: Using System; Using System.Collections.Generic; Using System.Linq; Using System.Text; Using System.Configuration;
Namespace Shop.dataaccess { public class Dataaccessbase { Name of the stored procedure Protected string StoredProcedureName {set; get;}
Get connection string Protected string ConnectionString { Get { return configurationmanager.connectionstrings["Db_shopconnectionstring"]. ToString (); } } }
} |
Storeprocedure Class in class library
Stored Procedure names written using enumeration storage to make it easier to change and manage
But for a lot of stored procedures, a class to store is certainly not enough, personal recommendations in the subdivision, control a class of stored procedures not more than 20
For example:
Storeprocedure_user,storeprocedure_product,storeprocedure_orders
The following are the referenced contents: Using System; Using System.Collections.Generic; Using System.Linq; Using System.Text;
Namespace Shop.dataaccess { public class StoredProcedure { public enum Name { Productbyid_select, Products_select, Products_selectserach, Shoppingcart_select, Shoppingcart_insert, Shoppingcart_update, Shoppingcart_delete, Enduser_insert, Enduserlogin_select, Address_select, Contactinformation_select, Adminlogin_select, Product_insert, Productcategory_select, Product_update, Orders_select, Orderdetails_select, Orderall_select, Orderstatus_select, Ordersbyid_select, Orders_update, Productpromotion_select } } } |