包括生成Insert,Update存儲過程,實體類和View類。
以及上面幾種代碼的批量生成模板。
所生成的代碼如下:
代碼/*
*本代碼由代碼生成器自動生成,請不要更改此文件的任何代碼,如需要添加方法,請創建同名類,并在該類中添加新的方法。
*生成時間:2010-11-2 9:44:44
*生成者:Kuibono
*/
using System;
using System.Text;
using System.Data;
using System.Linq;
using System.Data.SqlClient;
using System.Collections.Generic;
using WanerSoft;
using WanerSoft.Model;
using WanerSoft.Config;
using WanerSoft.Data.SqlClient;
using WanerSoft.Setting;
namespace WanerSoft.DAL
{
///<summary>
///表Ws_Setting的數據操作類
///</summary>
public partial class Ws_SettingView
{
#region 將數據插入表
/// <summary>
/// 將數據插入表
/// </summary>
/// <param name="M">賦值后的實體</param>
/// <returns></returns>
public static void Insert(Ws_Setting M)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
Sql.Add("@K",SqlDbType.NVarChar,M.K,50);
Sql.Add("@V",SqlDbType.NText,M.V);
Sql.ExecuteNonQuery("Ws_Setting_Insert").ToString();
}
/// <summary>
/// 將數據插入表
/// </summary>
/// <param name="M">賦值后的實體</param>
/// <returns>返回ID</returns>
public static int InsertAndReturnPK(Ws_Setting M)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
Sql.Add("@K",SqlDbType.NVarChar,M.K,50);
Sql.Add("@V",SqlDbType.NText,M.V);
return Convert.ToInt32(Sql.ExecuteScalar("Ws_Setting_Insert").ToString());
}
#endregion
#region Update將修改過的實體修改到數據庫
/// <summary>
/// 將修改過的實體修改到數據庫
/// </summary>
/// <param name="M">賦值后的實體</param>
/// <returns></returns>
public static void Update(Ws_Setting M)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
Sql.Add("@id",M.Id);
Sql.Add("@K",SqlDbType.NVarChar,M.K,50);
Sql.Add("@V",SqlDbType.NText,M.V);
Sql.ExecuteNonQuery("Ws_Setting_Update");
}
#endregion
#region 根據ID取得實體
/// <summary>
/// 根據ID取得實體
/// </summary>
/// <param name="id">id,即編號主鍵</param>
/// <returns></returns>
public static Ws_Setting GetModelByID(int id)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
Ws_Setting M = new Ws_Setting();
SqlDataReader Rs = Sql.ExecuteReader(CommandType.Text, "select id,K,V from Ws_Setting where Id=" + id.ToString(), SqlHelper.ConnClose.Yes);
if (!Rs.Read())
{
M.Id=int.MinValue;
}
else
{
M.Id=Rs["id"].ToInt32();
M.K=Rs["K"].ToString();
M.V=Rs["V"].ToString();
}
Rs.Close();
Rs = null;
return M;
}
#endregion
#region 根據條件語句取得第一個實體
/// <summary>
/// 根據條件語句取得第一個實體
/// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static Ws_Setting Find(string m_where)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
Ws_Setting M = new Ws_Setting();
SqlDataReader Rs = Sql.ExecuteReader(CommandType.Text, "select id,K,V from Ws_Setting where " + m_where, SqlHelper.ConnClose.Yes);
if (!Rs.Read())
{
M.Id=int.MinValue;
}
else
{
M.Id=Rs["id"].ToInt32();
M.K=Rs["K"].ToString();
M.V=Rs["V"].ToString();
}
Rs.Close();
Rs = null;
return M;
}
#endregion
#region 根據條件語句取得符合條件的數據表
/// <summary>
/// 根據條件語句取得符合條件的數據表,慎用?。。。?br> /// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static DataTable getTable(string m_where)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
return Sql.ExecuteDataTable(CommandType.Text, "select id,K,V from Ws_Setting where "+ m_where);
}
/// <summary>
/// 根據條件語句取得符合條件的數據表,慎用?。。?!
/// </summary>
/// <returns></returns>
public static DataTable getTable()
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
DataTable dt=Sql.ExecuteDataTable(CommandType.Text, "select id,K,V from Ws_Setting");
return dt;
}
/// <summary>
/// 根據條件語句取得符合條件的數據表,慎用!?。?!
/// </summary>
/// <param name="top">前多少條數據</param>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static DataTable getTable(string m_where,int top)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
DataTable dt=Sql.ExecuteDataTable(CommandType.Text, "select top "+ top.ToString() +" id,K,V from Ws_Setting where "+ m_where);
return dt;
}
#endregion
#region 根據條件語句取得符合條件的數據集數據集
/// <summary>
/// 根據條件語句取得符合條件的數據集數據集,慎用!!!!
/// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static DataSet getDs(string m_where)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
return Sql.ExecuteDataSet(CommandType.Text, "select id,K,V from Ws_Setting where "+ m_where);
}
/// <summary>
/// 根據條件語句取得符合條件的數據集數據集,慎用?。。。?br> /// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static DataSet getDs()
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
return Sql.ExecuteDataSet(CommandType.Text, "select id,K,V from Ws_Setting");
}
#endregion
#region 獲取符合條件記錄的條數
/// <summary>
/// 獲取符合條件記錄的條數
/// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static int Count(string m_where)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
return Convert.ToInt32(Sql.ExecuteScalar(CommandType.Text,"select count(0) from Ws_Setting where "+m_where));
}
#endregion
#region 驗證符合條件的記錄是否存在
/// <summary>
/// 驗證符合條件的記錄是否存在
/// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static bool Exist(string m_where)
{
bool returnValue = false;
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
SqlDataReader sd = null;
sd = Sql.ExecuteReader(CommandType.Text, "select max(Id) from Ws_Setting where " + m_where, SqlHelper.ConnClose.Yes);
if (sd.Read())
{
returnValue = true;
}
sd.Close();
sd.Dispose();
return returnValue;
}
#endregion
#region List<Ws_Setting>獲取符合條件記錄的實體列表,慎用?。。。?/span>
/// <summary>
/// List<Ws_Setting>獲取符合條件記錄的實體列表,慎用?。。?!
/// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static List<Ws_Setting> GetModelList(string m_where)
{
List<Ws_Setting> Ms=new List<Ws_Setting>();
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
DataTable dt=Sql.ExecuteDataTable(CommandType.Text, "select id,K,V from Ws_Setting where "+m_where);
for(int i=0;i<dt.Rows.Count;i++)
{
Ws_Setting M=new Ws_Setting();
M.Id=dt.Rows[i]["id"].ToInt32();
M.K=dt.Rows[i]["K"].ToString();
M.V=dt.Rows[i]["V"].ToString();
Ms.Add(M);
}
return Ms;
}
public static List<Ws_Setting> GetModelList(string m_where,int top)
{
List<Ws_Setting> Ms=new List<Ws_Setting>();
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
DataTable dt=Sql.ExecuteDataTable(CommandType.Text, "select top "+ top.ToString() +" id,K,V from Ws_Setting where "+m_where);
for(int i=0;i<dt.Rows.Count;i++)
{
Ws_Setting M=new Ws_Setting();
M.Id=dt.Rows[i]["id"].ToInt32();
M.K=dt.Rows[i]["K"].ToString();
M.V=dt.Rows[i]["V"].ToString();
Ms.Add(M);
}
return Ms;
}
public static List<Ws_Setting> GetModelList()
{
List<Ws_Setting> Ms = new List<Ws_Setting>();
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
DataTable dt=Sql.ExecuteDataTable(CommandType.Text, "select id,K,V from Ws_Setting ");
for (int i = 0; i < dt.Rows.Count; i++)
{
Ws_Setting M=new Ws_Setting();
M.Id=dt.Rows[i]["id"].ToInt32();
M.K=dt.Rows[i]["K"].ToString();
M.V=dt.Rows[i]["V"].ToString();
Ms.Add(M);
}
return Ms;
}
#endregion
#region 刪除符合條件記錄
/// <summary>
/// 刪除符合條件記錄
/// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static bool Del(string m_where)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
try
{
Sql.ExecuteNonQuery(CommandType.Text, "delete from Ws_Setting where "+ m_where);
return true;
}
catch
{
return false;
}
}
#endregion
#region 刪除符合條件記錄
/// <summary>
/// 刪除符合條件記錄
/// </summary>
/// <param name="ID">ID</param>
/// <returns></returns>
public static bool DelByID(int ID)
{
return Del("Id="+ID.ToString());
}
#endregion
}
}
*本代碼由代碼生成器自動生成,請不要更改此文件的任何代碼,如需要添加方法,請創建同名類,并在該類中添加新的方法。
*生成時間:2010-11-2 9:44:44
*生成者:Kuibono
*/
using System;
using System.Text;
using System.Data;
using System.Linq;
using System.Data.SqlClient;
using System.Collections.Generic;
using WanerSoft;
using WanerSoft.Model;
using WanerSoft.Config;
using WanerSoft.Data.SqlClient;
using WanerSoft.Setting;
namespace WanerSoft.DAL
{
///<summary>
///表Ws_Setting的數據操作類
///</summary>
public partial class Ws_SettingView
{
#region 將數據插入表
/// <summary>
/// 將數據插入表
/// </summary>
/// <param name="M">賦值后的實體</param>
/// <returns></returns>
public static void Insert(Ws_Setting M)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
Sql.Add("@K",SqlDbType.NVarChar,M.K,50);
Sql.Add("@V",SqlDbType.NText,M.V);
Sql.ExecuteNonQuery("Ws_Setting_Insert").ToString();
}
/// <summary>
/// 將數據插入表
/// </summary>
/// <param name="M">賦值后的實體</param>
/// <returns>返回ID</returns>
public static int InsertAndReturnPK(Ws_Setting M)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
Sql.Add("@K",SqlDbType.NVarChar,M.K,50);
Sql.Add("@V",SqlDbType.NText,M.V);
return Convert.ToInt32(Sql.ExecuteScalar("Ws_Setting_Insert").ToString());
}
#endregion
#region Update將修改過的實體修改到數據庫
/// <summary>
/// 將修改過的實體修改到數據庫
/// </summary>
/// <param name="M">賦值后的實體</param>
/// <returns></returns>
public static void Update(Ws_Setting M)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
Sql.Add("@id",M.Id);
Sql.Add("@K",SqlDbType.NVarChar,M.K,50);
Sql.Add("@V",SqlDbType.NText,M.V);
Sql.ExecuteNonQuery("Ws_Setting_Update");
}
#endregion
#region 根據ID取得實體
/// <summary>
/// 根據ID取得實體
/// </summary>
/// <param name="id">id,即編號主鍵</param>
/// <returns></returns>
public static Ws_Setting GetModelByID(int id)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
Ws_Setting M = new Ws_Setting();
SqlDataReader Rs = Sql.ExecuteReader(CommandType.Text, "select id,K,V from Ws_Setting where Id=" + id.ToString(), SqlHelper.ConnClose.Yes);
if (!Rs.Read())
{
M.Id=int.MinValue;
}
else
{
M.Id=Rs["id"].ToInt32();
M.K=Rs["K"].ToString();
M.V=Rs["V"].ToString();
}
Rs.Close();
Rs = null;
return M;
}
#endregion
#region 根據條件語句取得第一個實體
/// <summary>
/// 根據條件語句取得第一個實體
/// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static Ws_Setting Find(string m_where)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
Ws_Setting M = new Ws_Setting();
SqlDataReader Rs = Sql.ExecuteReader(CommandType.Text, "select id,K,V from Ws_Setting where " + m_where, SqlHelper.ConnClose.Yes);
if (!Rs.Read())
{
M.Id=int.MinValue;
}
else
{
M.Id=Rs["id"].ToInt32();
M.K=Rs["K"].ToString();
M.V=Rs["V"].ToString();
}
Rs.Close();
Rs = null;
return M;
}
#endregion
#region 根據條件語句取得符合條件的數據表
/// <summary>
/// 根據條件語句取得符合條件的數據表,慎用?。。。?br> /// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static DataTable getTable(string m_where)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
return Sql.ExecuteDataTable(CommandType.Text, "select id,K,V from Ws_Setting where "+ m_where);
}
/// <summary>
/// 根據條件語句取得符合條件的數據表,慎用?。。?!
/// </summary>
/// <returns></returns>
public static DataTable getTable()
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
DataTable dt=Sql.ExecuteDataTable(CommandType.Text, "select id,K,V from Ws_Setting");
return dt;
}
/// <summary>
/// 根據條件語句取得符合條件的數據表,慎用!?。?!
/// </summary>
/// <param name="top">前多少條數據</param>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static DataTable getTable(string m_where,int top)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
DataTable dt=Sql.ExecuteDataTable(CommandType.Text, "select top "+ top.ToString() +" id,K,V from Ws_Setting where "+ m_where);
return dt;
}
#endregion
#region 根據條件語句取得符合條件的數據集數據集
/// <summary>
/// 根據條件語句取得符合條件的數據集數據集,慎用!!!!
/// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static DataSet getDs(string m_where)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
return Sql.ExecuteDataSet(CommandType.Text, "select id,K,V from Ws_Setting where "+ m_where);
}
/// <summary>
/// 根據條件語句取得符合條件的數據集數據集,慎用?。。。?br> /// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static DataSet getDs()
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
return Sql.ExecuteDataSet(CommandType.Text, "select id,K,V from Ws_Setting");
}
#endregion
#region 獲取符合條件記錄的條數
/// <summary>
/// 獲取符合條件記錄的條數
/// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static int Count(string m_where)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
return Convert.ToInt32(Sql.ExecuteScalar(CommandType.Text,"select count(0) from Ws_Setting where "+m_where));
}
#endregion
#region 驗證符合條件的記錄是否存在
/// <summary>
/// 驗證符合條件的記錄是否存在
/// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static bool Exist(string m_where)
{
bool returnValue = false;
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
SqlDataReader sd = null;
sd = Sql.ExecuteReader(CommandType.Text, "select max(Id) from Ws_Setting where " + m_where, SqlHelper.ConnClose.Yes);
if (sd.Read())
{
returnValue = true;
}
sd.Close();
sd.Dispose();
return returnValue;
}
#endregion
#region List<Ws_Setting>獲取符合條件記錄的實體列表,慎用?。。。?/span>
/// <summary>
/// List<Ws_Setting>獲取符合條件記錄的實體列表,慎用?。。?!
/// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static List<Ws_Setting> GetModelList(string m_where)
{
List<Ws_Setting> Ms=new List<Ws_Setting>();
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
DataTable dt=Sql.ExecuteDataTable(CommandType.Text, "select id,K,V from Ws_Setting where "+m_where);
for(int i=0;i<dt.Rows.Count;i++)
{
Ws_Setting M=new Ws_Setting();
M.Id=dt.Rows[i]["id"].ToInt32();
M.K=dt.Rows[i]["K"].ToString();
M.V=dt.Rows[i]["V"].ToString();
Ms.Add(M);
}
return Ms;
}
public static List<Ws_Setting> GetModelList(string m_where,int top)
{
List<Ws_Setting> Ms=new List<Ws_Setting>();
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
DataTable dt=Sql.ExecuteDataTable(CommandType.Text, "select top "+ top.ToString() +" id,K,V from Ws_Setting where "+m_where);
for(int i=0;i<dt.Rows.Count;i++)
{
Ws_Setting M=new Ws_Setting();
M.Id=dt.Rows[i]["id"].ToInt32();
M.K=dt.Rows[i]["K"].ToString();
M.V=dt.Rows[i]["V"].ToString();
Ms.Add(M);
}
return Ms;
}
public static List<Ws_Setting> GetModelList()
{
List<Ws_Setting> Ms = new List<Ws_Setting>();
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
DataTable dt=Sql.ExecuteDataTable(CommandType.Text, "select id,K,V from Ws_Setting ");
for (int i = 0; i < dt.Rows.Count; i++)
{
Ws_Setting M=new Ws_Setting();
M.Id=dt.Rows[i]["id"].ToInt32();
M.K=dt.Rows[i]["K"].ToString();
M.V=dt.Rows[i]["V"].ToString();
Ms.Add(M);
}
return Ms;
}
#endregion
#region 刪除符合條件記錄
/// <summary>
/// 刪除符合條件記錄
/// </summary>
/// <param name="m_where">條件語句,不包含“where”</param>
/// <returns></returns>
public static bool Del(string m_where)
{
SqlHelper Sql = new SqlHelper(ConnStr.SystemConnStr);
try
{
Sql.ExecuteNonQuery(CommandType.Text, "delete from Ws_Setting where "+ m_where);
return true;
}
catch
{
return false;
}
}
#endregion
#region 刪除符合條件記錄
/// <summary>
/// 刪除符合條件記錄
/// </summary>
/// <param name="ID">ID</param>
/// <returns></returns>
public static bool DelByID(int ID)
{
return Del("Id="+ID.ToString());
}
#endregion
}
}
下載地址:

浙公網安備 33010602011771號