A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

  1.    public class Order : IOrder {

  2.         //Static constants
  3.                 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;";
  4.         private const string SQL_INSERT_ITEM = "INSERT INTO LineItem VALUES( ";
  5.         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";
  6.         private const string PARM_USER_ID = "@UserId";
  7.         private const string PARM_DATE = "@Date";
  8.         private const string PARM_SHIP_ADDRESS1 = "@ShipAddress1";
  9.         private const string PARM_SHIP_ADDRESS2 = "@ShipAddress2";
  10.         private const string PARM_SHIP_CITY = "@ShipCity";
  11.         private const string PARM_SHIP_STATE = "@ShipState";
  12.         private const string PARM_SHIP_ZIP = "@ShipZip";
  13.         private const string PARM_SHIP_COUNTRY = "@ShipCountry";
  14.         private const string PARM_BILL_ADDRESS1 = "@BillAddress1";
  15.         private const string PARM_BILL_ADDRESS2 = "@BillAddress2";
  16.         private const string PARM_BILL_CITY = "@BillCity";
  17.         private const string PARM_BILL_STATE = "@BillState";
  18.         private const string PARM_BILL_ZIP = "@BillZip";
  19.         private const string PARM_BILL_COUNTRY = "@BillCountry";
  20.         private const string PARM_TOTAL = "@Total";
  21.         private const string PARM_BILL_FIRST_NAME = "@BillFirstName";
  22.         private const string PARM_BILL_LAST_NAME = "@BillLastName";
  23.         private const string PARM_SHIP_FIRST_NAME = "@ShipFirstName";
  24.         private const string PARM_SHIP_LAST_NAME = "@ShipLastName";
  25.                 private const string PARM_AUTHORIZATION_NUMBER = "@AuthorizationNumber";  
  26.         private const string PARM_ORDER_ID = "@OrderId";
  27.         private const string PARM_LINE_NUMBER = "@LineNumber";
  28.         private const string PARM_ITEM_ID = "@ItemId";
  29.         private const string PARM_QUANTITY = "@Quantity";
  30.         private const string PARM_PRICE = "@Price";
  31. ....................
复制代码
类似的大量使用常量,在一定程度上减少了代码中直接写table字段名的可能产生的书写错误,但这样,在new 一个实例时,岂不添加了额外的内存开销???不太懂低层,求高手解释

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马