SqlHelper.cst 生成sql处理类

  1<%-- 
  2Name:
  3Author: 
  4Description: 
  5--%>
  6<%@ CodeTemplate Language="C#" ResponseEncoding="UTF-8" TargetLanguage="Text" Src="" Inherits="" Debug="False" Description="Template description here." %>
  7<%@ Property Name="NameSpace" Type="System.String" Default="" Optional="true" Category="命名空间" Description="当前生成实体类的命名空间" %>
  8<%@ Assembly Name="System.Data" %>
  9<%@ Import Namespace="System.Data" %>
 10
 11
 12using System;
 13using System.Data;
 14using System.Data.Sql;
 15using System.Data.SqlClient;
 16using System.Collections.Generic;
 17using System.Text;
 18using System.Configuration;
 19using System.Globalization;
 20
 21
 22namespace <%= NameSpace%>.Providers
 23{
 24    /// <summary>
 25    /// SqlHelper
 26    /// </summary>

 27    public static partial class SqlHelper
 28    {
 29        /// <summary>
 30        /// 准备SqlCommand
 31        /// </summary>
 32        /// <param name="commandText"> 存储过程名 </param>
 33        /// <param name="parameters"> 参数集 </param>
 34        /// <param name="conn"> 数据连接对象 </param>
 35        /// <returns> SqlCommand </returns>

 36        public static SqlCommand PrepareCommand(string commandText, SqlConnection conn, CommandType commandType)
 37        {
 38            SqlCommand cmd = new SqlCommand();
 39            cmd.Connection = conn;
 40            cmd.CommandType = commandType;
 41            cmd.CommandText = commandText;
 42           
 43            return cmd;
 44        }

 45
 46        SQL参数生成:static MakeInParam,static MakeOutParam
108    }

109}

110
111<script runat="template">
112// My methods here.
113
114public string SampleMethod()
115{
116    return "Method output.";
117}

118</script>
posted @ 2007-07-05 20:00  吴碧宇  阅读(549)  评论(1编辑  收藏  举报