CodeSmith 第一次用,遇到问题了

这个东西安装好久了,一直没什么机会用,昨天研究了一下,发现生成的代码在vs2005中没办法使用,先贴上来,看看到时候找到解决方法了再上来解决,要是有人知道,麻烦告知。

CodeSmith 4.0 Samples\DatabaseSchema\businessobject.cst,输入表名后生成一个用来操作表的类,但是这个类中用到了一个SqlService sql = new SqlService();,放到vs中提示找不到类型或命名空间名称“SqlService”(是否缺少 using 指令或程序集引用?),不知道怎么解决。求助。

代码如下:
  1 title #region title
  2    /**//// <summary>
  3    /// This object represents the properties and methods of a title.
  4    /// </summary>

  5    public class title
  6    {
  7        protected string _id;
  8        protected string _title = String.Empty;
  9        protected string _type = String.Empty;
 10        protected string _pub_id = String.Empty;
 11        protected decimal _price;
 12        protected decimal _advance;
 13        protected int _royalty;
 14        protected int _ytd_sales;
 15        protected string _notes = String.Empty;
 16        protected DateTime _pubdate;
 17        
 18        public title()
 19        {
 20        }

 21        
 22        public title(string id)
 23        {
 24            SqlService sql = new SqlService();
 25            sql.AddParameter("@title_id", SqlDbType.__UNKNOWN__tid, id);
 26            SqlDataReader reader = sql.ExecuteSqlReader("SELECT * FROM titles WHERE title_id = '" + id.ToString() + "'");
 27            
 28            if (reader.Read()) 
 29            {
 30                this.LoadFromReader(reader);
 31                reader.Close();
 32            }

 33            else
 34            {
 35                if (!reader.IsClosed) reader.Close();
 36                throw new ApplicationException("title does not exist.");
 37            }

 38        }

 39        
 40        public title(SqlDataReader reader)
 41        {
 42            this.LoadFromReader(reader);
 43        }

 44        
 45        protected void LoadFromReader(SqlDataReader reader)
 46        {
 47            if (reader != null && !reader.IsClosed)
 48            {
 49                _id = reader.GetString(0);
 50                if (!reader.IsDBNull(1)) _title = reader.GetString(1);
 51                if (!reader.IsDBNull(2)) _type = reader.GetString(2);
 52                if (!reader.IsDBNull(3)) _pub_id = reader.GetString(3);
 53                if (!reader.IsDBNull(4)) _price = reader.GetDecimal(4);
 54                if (!reader.IsDBNull(5)) _advance = reader.GetDecimal(5);
 55                if (!reader.IsDBNull(6)) _royalty = reader.GetInt32(6);
 56                if (!reader.IsDBNull(7)) _ytd_sales = reader.GetInt32(7);
 57                if (!reader.IsDBNull(8)) _notes = reader.GetString(8);
 58                if (!reader.IsDBNull(9)) _pubdate = reader.GetDateTime(9);
 59            }

 60        }

 61        
 62        Public Properties#region Public Properties
 63        public string Id
 64        {
 65            get {return _id;}
 66        }

 67        
 68        public string title
 69        {
 70            get {return _title;}
 71            set {_title = value;}
 72        }

 73
 74        public string type
 75        {
 76            get {return _type;}
 77            set {_type = value;}
 78        }

 79
 80        public string pub_id
 81        {
 82            get {return _pub_id;}
 83            set {_pub_id = value;}
 84        }

 85
 86        public decimal price
 87        {
 88            get {return _price;}
 89            set {_price = value;}
 90        }

 91
 92        public decimal advance
 93        {
 94            get {return _advance;}
 95            set {_advance = value;}
 96        }

 97
 98        public int royalty
 99        {
100            get {return _royalty;}
101            set {_royalty = value;}
102        }

103
104        public int ytd_sales
105        {
106            get {return _ytd_sales;}
107            set {_ytd_sales = value;}
108        }

109
110        public string notes
111        {
112            get {return _notes;}
113            set {_notes = value;}
114        }

115
116        public DateTime pubdate
117        {
118            get {return _pubdate;}
119            set {_pubdate = value;}
120        }

121        #endregion

122        
123        public static title Gettitle(string id)
124        {
125            return new title(id);
126        }

127    }

128    #endregion

129



转载于:https://www.cnblogs.com/bluesky4485/archive/2008/03/03/1088652.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值