- public class Order : IOrder {
- //Static constants
- private const string SQL_INSERT_ORDER = "Declare @ID int; Declare @ERR int; INSERT INTO Orders VALUES(@UserId, @Date, @ShipAddress1, @ShipAddress2, @ShipCity, @ShipState, @ShipZip, @ShipCountry, @BillAddress1, @BillAddress2, @BillCity, @BillState, @BillZip, @BillCountry, 'UPS', @Total, @BillFirstName, @BillLastName, @ShipFirstName, @ShipLastName, @AuthorizationNumber, 'US_en'); SELECT @ID=@@IDENTITY; INSERT INTO OrderStatus VALUES(@ID, @ID, GetDate(), 'P'); SELECT @ERR=@@ERROR;";
- private const string SQL_INSERT_ITEM = "INSERT INTO LineItem VALUES( ";
- private const string SQL_SELECT_ORDER = "SELECT o.OrderDate, o.UserId, o.CardType, o.CreditCard, o.ExprDate, o.BillToFirstName, o.BillToLastName, o.BillAddr1, o.BillAddr2, o.BillCity, o.BillState, BillZip, o.BillCountry, o.ShipToFirstName, o.ShipToLastName, o.ShipAddr1, o.ShipAddr2, o.ShipCity, o.ShipState, o.ShipZip, o.ShipCountry, o.TotalPrice, l.ItemId, l.LineNum, l.Quantity, l.UnitPrice FROM Orders as o, lineitem as l WHERE o.OrderId = @OrderId AND o.orderid = l.orderid";
- private const string PARM_USER_ID = "@UserId";
- private const string PARM_DATE = "@Date";
- private const string PARM_SHIP_ADDRESS1 = "@ShipAddress1";
- private const string PARM_SHIP_ADDRESS2 = "@ShipAddress2";
- private const string PARM_SHIP_CITY = "@ShipCity";
- private const string PARM_SHIP_STATE = "@ShipState";
- private const string PARM_SHIP_ZIP = "@ShipZip";
- private const string PARM_SHIP_COUNTRY = "@ShipCountry";
- private const string PARM_BILL_ADDRESS1 = "@BillAddress1";
- private const string PARM_BILL_ADDRESS2 = "@BillAddress2";
- private const string PARM_BILL_CITY = "@BillCity";
- private const string PARM_BILL_STATE = "@BillState";
- private const string PARM_BILL_ZIP = "@BillZip";
- private const string PARM_BILL_COUNTRY = "@BillCountry";
- private const string PARM_TOTAL = "@Total";
- private const string PARM_BILL_FIRST_NAME = "@BillFirstName";
- private const string PARM_BILL_LAST_NAME = "@BillLastName";
- private const string PARM_SHIP_FIRST_NAME = "@ShipFirstName";
- private const string PARM_SHIP_LAST_NAME = "@ShipLastName";
- private const string PARM_AUTHORIZATION_NUMBER = "@AuthorizationNumber";
- private const string PARM_ORDER_ID = "@OrderId";
- private const string PARM_LINE_NUMBER = "@LineNumber";
- private const string PARM_ITEM_ID = "@ItemId";
- private const string PARM_QUANTITY = "@Quantity";
- private const string PARM_PRICE = "@Price";
- ....................
复制代码 类似的大量使用常量,在一定程度上减少了代码中直接写table字段名的可能产生的书写错误,但这样,在new 一个实例时,岂不添加了额外的内存开销???不太懂低层,求高手解释 |
|