当前位置: 首页 > news >正文

开源网站模板cmsseo是什么

开源网站模板cms,seo是什么,做网站 找风投,网站建设流程与步骤主要跟大家交流下T4,我这里针对的是mysql,我本人比较喜欢用mysql,所以语法针对mysql,所以你要准备mysql的DLL了,同理sqlserver差不多,有兴趣可以自己写写,首先网上找了一个T4的帮助类,得到一些数据库属性,命名为 DbHelper.ttinclude # template debugfalse hos…主要跟大家交流下T4,我这里针对的是mysql,我本人比较喜欢用mysql,所以语法针对mysql,所以你要准备mysql的DLL了,同理sqlserver差不多,有兴趣可以自己写写,首先网上找了一个T4的帮助类,得到一些数据库属性,命名为 DbHelper.ttinclude # template debugfalse hostspecificfalse languageC# # # assembly nameSystem.Core.dll # # assembly nameSystem.Data.dll # # assembly nameSystem.Data.DataSetExtensions.dll # # assembly nameSystem.Xml.dll # # assembly nameMySql.Data # # import namespaceSystem # # import namespaceSystem.Xml # # import namespaceSystem.Linq # # import namespaceSystem.Text # # import namespaceSystem.Data # # import namespace System.Data.SqlClient # # import namespaceMySql.Data.MySqlClient # # import namespaceSystem.Collections.Generic # # import namespaceSystem.IO # # import namespaceSystem.Text.RegularExpressions ###region GetDbTablespublic class DbHelper{#region 去下划线,转大写public static string ToSplitFirstUpper(string file){string[] words file.Split(_);StringBuilder firstUpperWorld new StringBuilder();foreach (string word in words){string firstUpper ToFirstUpper(word);firstUpperWorld.Append(firstUpper);}string firstUpperFile firstUpperWorld.ToString().TrimEnd(new char[] { _ });return firstUpperFile;}// 将字符串设置成首字母大写public static string ToFirstUpper(string field){string first field.Substring(0, 1).ToUpperInvariant();string result first;if (field.Length 1){string after field.Substring(1);result first after;}return result;}#endregion#region 生成简单的sql语句public static string GetInsertSql(string connectionString, string database, string tableName){var list GetDbColumns(connectionString, database, tableName);StringBuilder sb1 new StringBuilder();StringBuilder sb2 new StringBuilder();foreach (var item in list){string field item.Field;if (field.ToLower() id) continue;sb1.Append(field).Append(, );sb2.Append(?).Append(field).Append(, );}string s1 sb1.ToString().Trim(new char[] { ,, });string s2 sb2.ToString().Trim(new char[] { ,, });return string.Format(INSERT INTO {0}({1}) VALUES({2}), tableName, s1, s2);}public static string GetParameter(string connectionString, string database, string tableName, bool hasId){var list GetDbColumns(connectionString, database, tableName);StringBuilder sb new StringBuilder();sb.Append(MySqlParameter[] paras new MySqlParameter[] { \r\n);foreach (var item in list){if (item.Field.ToLower() id !hasId) continue;sb.AppendFormat( new MySqlParameter(\{0}\, this.{1}),\r\n, item.Field, ToSplitFirstUpper(item.Field));}string s sb.ToString().Trim(new char[] { ,, , \r, \n });s s \r\n };\r\n;return s;}public static string GetUpdateSql(string connectionString, string database, string tableName){var list GetDbColumns(connectionString, database, tableName);StringBuilder sb1 new StringBuilder();foreach (var item in list){string field item.Field;if (field.ToLower() id) continue;sb1.Append(field).Append( ).Append(?).Append(field).Append(, );}string s1 sb1.ToString().Trim(new char[] { ,, });return string.Format(UPDATE {0} SET {1} WHERE id ?id, tableName, s1);}#endregion#region GetDbTablespublic static ListDbTable GetDbTables(string connectionString, string database){#region SQLstring sql string.Format(SHOW TABLE STATUS FROM {0};, database);#endregionDataTable dt GetDataTable(connectionString, sql);return dt.Rows.CastDataRow().Select(row new DbTable{TableName row.Fieldstring(Name),Rows row.FieldUInt64(Rows),Comment row.Fieldstring(Comment)}).ToList();}#endregion#region GetDbColumnspublic static ListDbColumn GetDbColumns(string connectionString, string database, string tableName){#region SQLstring sql string.Format(SHOW FULL COLUMNS FROM {0} FROM {1};, tableName, database);#endregionDataTable dt GetDataTable(connectionString, sql);return dt.Rows.CastDataRow().Select(row new DbColumn{IsPrimaryKey !String.IsNullOrEmpty(row.Fieldstring(Key)),Field row.Fieldstring(Field),Type row.Fieldstring(Type),Comment row.Fieldstring(Comment),IsNullable row.Fieldstring(NULL) YES}).ToList();}#endregion#region GetDataTablepublic static DataTable GetDataTable(string connectionString, string commandText, params SqlParameter[] parms){using (MySqlConnection connection new MySqlConnection(connectionString)){MySqlCommand command connection.CreateCommand();command.CommandText commandText;command.Parameters.AddRange(parms);MySqlDataAdapter adapter new MySqlDataAdapter(command);DataTable dt new DataTable();adapter.Fill(dt);return dt;}}#endregion}#endregion#region DbTable/// summary/// 表结构/// /summarypublic sealed class DbTable{/// summary/// 表名称/// /summarypublic string TableName { get; set; }/// summary/// 行数/// /summarypublic UInt64 Rows { get; set; }/// summary/// 描述信息/// /summarypublic string Comment { get; set; }}#endregion#region DbColumn/// summary/// 表字段结构/// /summarypublic sealed class DbColumn{/// summary/// 是否主键/// /summarypublic bool IsPrimaryKey { get; set; }/// summary/// 字段名称/// /summarypublic string Field { get; set; }/// summary/// 字段类型 int(11)/// /summarypublic string Type { get; set; }/// summary/// 字段类型int/// /summarypublic string ColumnType{get{return Type.IndexOf(() -1 ? Type : Type.Substring(0, Type.IndexOf(());}}/// summary/// 数据库类型对应的C#类型/// /summarypublic string CSharpType{get{return MysqlDbTypeMap.MapCsharpType(ColumnType);}}/// summary/// /// /summarypublic Type CommonType{get{return MysqlDbTypeMap.MapCommonType(ColumnType);}}/// summary/// 描述/// /summarypublic string Comment { get; set; }/// summary/// 是否允许空/// /summarypublic bool IsNullable { get; set; }/// summary/// 字符长度/// /summarypublic int CharLength{get{Regex regex new Regex((?\()\d*?(?\)), RegexOptions.Singleline);if (regex.IsMatch(Type)){Match match regex.Match(Type);while (match ! null match.Success){int charLength;if (Int32.TryParse(match.Value, out charLength)){return charLength;}}}return 0;}}}#endregion#region SqlServerDbTypeMappublic class MysqlDbTypeMap{public static string MapCsharpType(string dbtype){if (string.IsNullOrEmpty(dbtype)) return dbtype;dbtype dbtype.ToLower();string csharpType object;switch (dbtype){case bigint: csharpType long; break;case binary: csharpType byte[]; break;case bit: csharpType bool; break;case char: csharpType string; break;case date: csharpType DateTime; break;case datetime: csharpType DateTime; break;case datetime2: csharpType DateTime; break;case datetimeoffset: csharpType DateTimeOffset; break;case dityint: csharpType bool; break;case decimal: csharpType decimal; break;case float: csharpType double; break;case image: csharpType byte[]; break;case int: csharpType int; break;case money: csharpType decimal; break;case nchar: csharpType string; break;case ntext: csharpType string; break;case numeric: csharpType decimal; break;case nvarchar: csharpType string; break;case real: csharpType Single; break;case smalldatetime: csharpType DateTime; break;case smallint: csharpType short; break;case smallmoney: csharpType decimal; break;case sql_variant: csharpType object; break;case sysname: csharpType object; break;case text: csharpType string; break;case longtext: csharpType string; break;case time: csharpType TimeSpan; break;case timestamp: csharpType byte[]; break;case tinyint: csharpType byte; break;case uniqueidentifier: csharpType Guid; break;case varbinary: csharpType byte[]; break;case varchar: csharpType string; break;case xml: csharpType string; break;default: csharpType object; break;}return csharpType;}public static Type MapCommonType(string dbtype){if (string.IsNullOrEmpty(dbtype)) return Type.Missing.GetType();dbtype dbtype.ToLower();Type commonType typeof(object);switch (dbtype){case bigint: commonType typeof(long); break;case binary: commonType typeof(byte[]); break;case bit: commonType typeof(bool); break;case char: commonType typeof(string); break;case date: commonType typeof(DateTime); break;case datetime: commonType typeof(DateTime); break;case datetime2: commonType typeof(DateTime); break;case datetimeoffset: commonType typeof(DateTimeOffset); break;case dityint: commonType typeof(Boolean); break;case decimal: commonType typeof(decimal); break;case float: commonType typeof(double); break;case image: commonType typeof(byte[]); break;case int: commonType typeof(int); break;case money: commonType typeof(decimal); break;case nchar: commonType typeof(string); break;case ntext: commonType typeof(string); break;case numeric: commonType typeof(decimal); break;case nvarchar: commonType typeof(string); break;case real: commonType typeof(Single); break;case smalldatetime: commonType typeof(DateTime); break;case smallint: commonType typeof(short); break;case smallmoney: commonType typeof(decimal); break;case sql_variant: commonType typeof(object); break;case sysname: commonType typeof(object); break;case text: commonType typeof(string); break;case time: commonType typeof(TimeSpan); break;case timestamp: commonType typeof(byte[]); break;case tinyint: commonType typeof(byte); break;case uniqueidentifier: commonType typeof(Guid); break;case varbinary: commonType typeof(byte[]); break;case varchar: commonType typeof(string); break;case xml: commonType typeof(string); break;default: commonType typeof(object); break;}return commonType;}}#endregion# View Code 在加一个c#的sql帮助类, 命名为DBHelper.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Data.SqlClient; using System.Security.Cryptography; using System.Configuration; using MySql.Data.MySqlClient; using System.Reflection; using System.Text;namespace ToolSite.Entity {public class DBHelper{//添加到配置文件的configuration节点中// connectionStrings// !--改写数据库名登陆名密码--// add nameconStr connectionStringData Source.;Initial Catalog;User ID;Password/// // /connectionStrings//appSettings// add keydbConnection valueserver192.168.1.111\SQL2005;databaseGCUMS;UIDsa;PWDsa;max pool size20000;Poolingtrue;/// /appSettings//先添加configuration引用引入命名空间//private static readonly string conStr ConfigurationManager.AppSettings[connstr]; //private static readonly string conStr Config.ConnStr;/// summary/// 获得连接字符串/// /summary/// returns/returnspublic static MySqlConnection getConn(){return new MySqlConnection(Config.ConnStr);}/// summary/// 查询获得首行首列的值格式化SQL语句/// /summary/// param namesql/param/// returns/returnspublic static object Scalar(String sql){using (MySqlConnection con getConn()){try{MySqlCommand com new MySqlCommand(sql, con);con.Open();return com.ExecuteScalar();}catch (Exception ex){throw ex;}}}/// summary/// 查询获得首行首列的值 参数化sql语句/// /summary/// param nameparas参数数组/param/// param namesqlsql语句/param/// returns/returnspublic static object Scalar(string sql, MySqlParameter[] paras){using (MySqlConnection con getConn()){try{MySqlCommand com new MySqlCommand(sql, con);con.Open();if (paras ! null) //如果参数{com.Parameters.AddRange(paras);}return com.ExecuteScalar();}catch (Exception ex){throw ex;}}}/// summary/// 增删改操作,返回受影响的行数格式化SQL语句/// /summary/// param namesql/param/// returns/returnspublic static int NoneQuery(String sql){using (MySqlConnection conn getConn()){conn.Open();using (MySqlCommand comm new MySqlCommand(sql, conn)){return comm.ExecuteNonQuery();}}}/// summary/// 增删改操作,返回受影响的行数 存储过程/// /summary/// param namesql存储过程名称/param/// param nameparas参数/param/// returns/returnspublic static int NoneQuery(String sql, MySqlParameter[] paras){using (MySqlConnection conn getConn()){conn.Open();using (MySqlCommand comm new MySqlCommand(sql, conn)){comm.Parameters.AddRange(paras);return comm.ExecuteNonQuery();}}}/// summary/// 查询操作,返回一个数据表/// /summary/// param namesql/param/// returns/returnspublic static DataTable GetDateTable(String sql){using (MySqlConnection con getConn()){DataTable dt new DataTable();try{MySqlDataAdapter sda new MySqlDataAdapter(sql, con);sda.Fill(dt);}catch (Exception ex){throw ex;}return dt;}}/// summary/// 查询操作,返回一个数据表,存储过程/// /summary/// param namesp_Name存储过程名称/param/// param nameparas存储过程参数/param/// returns/returnspublic static DataTable GetDateTable(String sql, MySqlParameter[] paras){using (MySqlConnection con getConn()){DataTable dt new DataTable();try{MySqlCommand com new MySqlCommand(sql, con);com.Parameters.AddRange(paras);MySqlDataAdapter sda new MySqlDataAdapter(com);sda.Fill(dt);}catch (Exception ex){throw ex;}return dt;}}}/// summary/// DataTable与实体类互相转换/// /summary/// typeparam nameT实体类/typeparampublic class DatatableFillT where T : new(){#region DataTable转换成实体类/// summary/// 填充对象列表用DataSet的第一个表填充实体类/// /summary/// param namedsDataSet/param/// returns/returnspublic ListT FillModel(DataSet ds){if (ds null || ds.Tables[0] null || ds.Tables[0].Rows.Count 0){return new ListT();}else{return FillModel(ds.Tables[0]);}}/// summary /// 填充对象列表用DataSet的第index个表填充实体类/// /summary public ListT FillModel(DataSet ds, int index){if (ds null || ds.Tables.Count index || ds.Tables[index].Rows.Count 0){return new ListT() ;}else{return FillModel(ds.Tables[index]);}}/// summary /// 填充对象列表用DataTable填充实体类/// /summary public ListT FillModel(DataTable dt){if (dt null || dt.Rows.Count 0){return new ListT();}ListT modelList new ListT();foreach (DataRow dr in dt.Rows){//T model (T)Activator.CreateInstance(typeof(T)); T model new T();for (int i 0; i dr.Table.Columns.Count; i){PropertyInfo propertyInfo model.GetType().GetProperty(ToSplitFirstUpper(dr.Table.Columns[i].ColumnName));if (propertyInfo ! null dr[i] ! DBNull.Value)propertyInfo.SetValue(model, dr[i], null);}modelList.Add(model);}return modelList;}/// summary /// 填充对象用DataRow填充实体类/// /summary public T FillModel(DataRow dr){if (dr null){return default(T);}//T model (T)Activator.CreateInstance(typeof(T)); T model new T();for (int i 0; i dr.Table.Columns.Count; i){PropertyInfo propertyInfo model.GetType().GetProperty(ToSplitFirstUpper(dr.Table.Columns[i].ColumnName));if (propertyInfo ! null dr[i] ! DBNull.Value)propertyInfo.SetValue(model, dr[i], null);}return model;}// 去下划线,转大写public static string ToSplitFirstUpper(string file){string[] words file.Split(_);StringBuilder firstUpperWorld new StringBuilder();foreach (string word in words){string firstUpper ToFirstUpper(word);firstUpperWorld.Append(firstUpper);}string firstUpperFile firstUpperWorld.ToString().TrimEnd(new char[] { _ });return firstUpperFile;}// 将字符串设置成首字母大写public static string ToFirstUpper(string field){string first field.Substring(0, 1).ToUpperInvariant();string result first;if (field.Length 1){string after field.Substring(1);result first after;}return result;}#endregion#region 实体类转换成DataTable/// summary/// 实体类转换成DataSet/// /summary/// param namemodelList实体类列表/param/// returns/returnspublic DataSet FillDataSet(ListT modelList){if (modelList null || modelList.Count 0){return null;}else{DataSet ds new DataSet();ds.Tables.Add(FillDataTable(modelList));return ds;}}/// summary/// 实体类转换成DataTable/// /summary/// param namemodelList实体类列表/param/// returns/returnspublic DataTable FillDataTable(ListT modelList){if (modelList null || modelList.Count 0){return null;}DataTable dt CreateData(modelList[0]);foreach (T model in modelList){DataRow dataRow dt.NewRow();foreach (PropertyInfo propertyInfo in typeof(T).GetProperties()){dataRow[propertyInfo.Name] propertyInfo.GetValue(model, null);}dt.Rows.Add(dataRow);}return dt;}/// summary/// 根据实体类得到表结构/// /summary/// param namemodel实体类/param/// returns/returnsprivate DataTable CreateData(T model){DataTable dataTable new DataTable(typeof(T).Name);foreach (PropertyInfo propertyInfo in typeof(T).GetProperties()){dataTable.Columns.Add(new DataColumn(propertyInfo.Name, propertyInfo.PropertyType));}return dataTable;}#endregion} } View Code 再家一个主要的T4文件,命名为 Entity.tt # include file$(ProjectDir)Entity/DbHelper.ttinclude# using System; using MySql.Data.MySqlClient; using System.Data; using System.Collections.Generic; namespace ToolSite.Entity {public class Config{public static string DefaultDb #config.DbDatabase#;public static string ConnStr #config.ConnectionString#;}#foreach(var table in DbHelper.GetDbTables(config.ConnectionString, config.DbDatabase)){# # string tableName DbHelper.ToSplitFirstUpper(table.TableName); #public partial class #tableName#{#region Field # foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, table.TableName)){#/// summary/// # column.Comment#/// /summarypublic # column.CSharpType# #DbHelper.ToSplitFirstUpper(column.Field)# { get; set; } #}# #endregionpublic int Save(){#DbHelper.GetParameter(config.ConnectionString, config.DbDatabase, table.TableName, false)#string sql #DbHelper.GetInsertSql(config.ConnectionString, config.DbDatabase, table.TableName)#;return DBHelper.NoneQuery(sql, paras);}public int Update(){#DbHelper.GetParameter(config.ConnectionString, config.DbDatabase, table.TableName, true)#string sql #DbHelper.GetUpdateSql(config.ConnectionString, config.DbDatabase, table.TableName)#;return DBHelper.NoneQuery(sql, paras);}public static int Delete(int id){string sql string.Format(DELETE FROM #table.TableName# WHERE id {0}, id);return DBHelper.NoneQuery(sql);}public static #tableName# GetById(int id){string sql string.Format(SELECT * FROM #table.TableName# WHERE id {0}, id);DataTable table DBHelper.GetDateTable(sql);List#tableName# list new DatatableFill#tableName#().FillModel(table);//List#tableName# list Mapper.DynamicMapIDataReader, List#tableName#(table.CreateDataReader());if (list null || list.Count 0) return null;return list[0];}public static List#tableName# GetList(){string sql SELECT * FROM #table.TableName#;DataTable table DBHelper.GetDateTable(sql);List#tableName# list new DatatableFill#tableName#().FillModel(table);//List#tableName# list Mapper.DynamicMapIDataReader, List#tableName#(table.CreateDataReader());return list;}public static List#tableName# Find(string where){string sql string.Format(SELECT * FROM #table.TableName# WHERE {0};, where);DataTable table DBHelper.GetDateTable(sql);return new DatatableFill#tableName#().FillModel(table);}public static List#tableName# Find(string field, string prop){return Find(string.Format( {0} {1} , field, prop));}public static bool Exist(string field, string prop){int n Count(field, prop);return n 0 ? true : false;}public static int Count(string where){string sql string.Format(SELECT COUNT(1) FROM #table.TableName# WHERE {0}, where);DataTable table DBHelper.GetDateTable(sql);return Convert.ToInt32(table.Rows[0][0]);}public static int Count(string field, string prop){return Count(string.Format( {0} {1} , field, prop));}public static int Count(){return Count( 1 1 );}public static List#tableName# Find(int index, int size, ref int count){count Count( 1 1 );string sql string.Format( 1 1 Order by id desc LIMIT {0}, {1} , index * size , size);return Find(sql);}public static List#tableName# Find(string field, string prop, int index, int size, ref int count){count Count(field, prop);string sql string.Format( {0} {1} Order by id desc LIMIT {2}, {3} , field, prop, index, size);return Find(sql);}}#}# }#class config{public static readonly string ConnectionString Server127.0.0.1;Databasetoolsite;Uidroot;Pwdroot;;public static readonly string DbDatabase toolsite;} # View Code 你需要改的是最后那个文件的这个位置 class config{public static readonly string ConnectionString Server127.0.0.1;Databasetoolsite;Uidroot;Pwdroot;;public static readonly string DbDatabase toolsite;} 怎么改我相信你懂的,点击下保存,你的实体类,跟数据库操作就生成了 最后生成的代码是这样子的,还是蛮粗糙的,如果你愿意改改,我相信会更好的!!! using System; using MySql.Data.MySqlClient; using System.Data; using System.Collections.Generic; namespace ToolSite.Entity {public class Config{public static string DefaultDb toolsite;public static string ConnStr Server127.0.0.1;Databasetoolsite;Uidroot;Pwdroot;;}public partial class PageInfo{#region Field/// summary/// /// /summarypublic int Id { get; set; }/// summary/// /// /summarypublic int SiteId { get; set; }/// summary/// /// /summarypublic int ParentId { get; set; }/// summary/// /// /summarypublic string FileName { get; set; }/// summary/// /// /summarypublic string Content { get; set; }/// summary/// /// /summarypublic string Title { get; set; }/// summary/// /// /summarypublic string Keywords { get; set; }/// summary/// /// /summarypublic string Description { get; set; }/// summary/// /// /summarypublic string H1 { get; set; }#endregionpublic int Save(){MySqlParameter[] paras new MySqlParameter[] { new MySqlParameter(site_id, this.SiteId),new MySqlParameter(parent_id, this.ParentId),new MySqlParameter(file_name, this.FileName),new MySqlParameter(content, this.Content),new MySqlParameter(title, this.Title),new MySqlParameter(keywords, this.Keywords),new MySqlParameter(description, this.Description),new MySqlParameter(h1, this.H1)};string sql INSERT INTO page_info(site_id, parent_id, file_name, content, title, keywords, description, h1) VALUES(?site_id, ?parent_id, ?file_name, ?content, ?title, ?keywords, ?description, ?h1);return DBHelper.NoneQuery(sql, paras);}public int Update(){MySqlParameter[] paras new MySqlParameter[] { new MySqlParameter(id, this.Id),new MySqlParameter(site_id, this.SiteId),new MySqlParameter(parent_id, this.ParentId),new MySqlParameter(file_name, this.FileName),new MySqlParameter(content, this.Content),new MySqlParameter(title, this.Title),new MySqlParameter(keywords, this.Keywords),new MySqlParameter(description, this.Description),new MySqlParameter(h1, this.H1)};string sql UPDATE page_info SET site_id ?site_id, parent_id ?parent_id, file_name ?file_name, content ?content, title ?title, keywords ?keywords, description ?description, h1 ?h1 WHERE id ?id;return DBHelper.NoneQuery(sql, paras);}public static int Delete(int id){string sql string.Format(DELETE FROM page_info WHERE id {0}, id);return DBHelper.NoneQuery(sql);}public static PageInfo GetById(int id){string sql string.Format(SELECT * FROM page_info WHERE id {0}, id);DataTable table DBHelper.GetDateTable(sql);ListPageInfo list new DatatableFillPageInfo().FillModel(table);//ListPageInfo list Mapper.DynamicMapIDataReader, ListPageInfo(table.CreateDataReader());if (list null || list.Count 0) return null;return list[0];}public static ListPageInfo GetList(){string sql SELECT * FROM page_info;DataTable table DBHelper.GetDateTable(sql);ListPageInfo list new DatatableFillPageInfo().FillModel(table);//ListPageInfo list Mapper.DynamicMapIDataReader, ListPageInfo(table.CreateDataReader());return list;}public static ListPageInfo Find(string where){string sql string.Format(SELECT * FROM page_info WHERE {0};, where);DataTable table DBHelper.GetDateTable(sql);return new DatatableFillPageInfo().FillModel(table);}public static ListPageInfo Find(string field, string prop){return Find(string.Format( {0} {1} , field, prop));}public static bool Exist(string field, string prop){int n Count(field, prop);return n 0 ? true : false;}public static int Count(string where){string sql string.Format(SELECT COUNT(1) FROM page_info WHERE {0}, where);DataTable table DBHelper.GetDateTable(sql);return Convert.ToInt32(table.Rows[0][0]);}public static int Count(string field, string prop){return Count(string.Format( {0} {1} , field, prop));}public static int Count(){return Count( 1 1 );}public static ListPageInfo Find(int index, int size, ref int count){count Count( 1 1 );string sql string.Format( 1 1 Order by id desc LIMIT {0}, {1} , index * size , size);return Find(sql);}public static ListPageInfo Find(string field, string prop, int index, int size, ref int count){count Count(field, prop);string sql string.Format( {0} {1} Order by id desc LIMIT {2}, {3} , field, prop, index, size);return Find(sql);}}public partial class SiteInfo{#region Field/// summary/// /// /summarypublic int Id { get; set; }/// summary/// /// /summarypublic string Name { get; set; }/// summary/// /// /summarypublic string Template { get; set; }#endregionpublic int Save(){MySqlParameter[] paras new MySqlParameter[] { new MySqlParameter(name, this.Name),new MySqlParameter(template, this.Template)};string sql INSERT INTO site_info(name, template) VALUES(?name, ?template);return DBHelper.NoneQuery(sql, paras);}public int Update(){MySqlParameter[] paras new MySqlParameter[] { new MySqlParameter(id, this.Id),new MySqlParameter(name, this.Name),new MySqlParameter(template, this.Template)};string sql UPDATE site_info SET name ?name, template ?template WHERE id ?id;return DBHelper.NoneQuery(sql, paras);}public static int Delete(int id){string sql string.Format(DELETE FROM site_info WHERE id {0}, id);return DBHelper.NoneQuery(sql);}public static SiteInfo GetById(int id){string sql string.Format(SELECT * FROM site_info WHERE id {0}, id);DataTable table DBHelper.GetDateTable(sql);ListSiteInfo list new DatatableFillSiteInfo().FillModel(table);//ListSiteInfo list Mapper.DynamicMapIDataReader, ListSiteInfo(table.CreateDataReader());if (list null || list.Count 0) return null;return list[0];}public static ListSiteInfo GetList(){string sql SELECT * FROM site_info;DataTable table DBHelper.GetDateTable(sql);ListSiteInfo list new DatatableFillSiteInfo().FillModel(table);//ListSiteInfo list Mapper.DynamicMapIDataReader, ListSiteInfo(table.CreateDataReader());return list;}public static ListSiteInfo Find(string where){string sql string.Format(SELECT * FROM site_info WHERE {0};, where);DataTable table DBHelper.GetDateTable(sql);return new DatatableFillSiteInfo().FillModel(table);}public static ListSiteInfo Find(string field, string prop){return Find(string.Format( {0} {1} , field, prop));}public static bool Exist(string field, string prop){int n Count(field, prop);return n 0 ? true : false;}public static int Count(string where){string sql string.Format(SELECT COUNT(1) FROM site_info WHERE {0}, where);DataTable table DBHelper.GetDateTable(sql);return Convert.ToInt32(table.Rows[0][0]);}public static int Count(string field, string prop){return Count(string.Format( {0} {1} , field, prop));}public static int Count(){return Count( 1 1 );}public static ListSiteInfo Find(int index, int size, ref int count){count Count( 1 1 );string sql string.Format( 1 1 Order by id desc LIMIT {0}, {1} , index * size , size);return Find(sql);}public static ListSiteInfo Find(string field, string prop, int index, int size, ref int count){count Count(field, prop);string sql string.Format( {0} {1} Order by id desc LIMIT {2}, {3} , field, prop, index, size);return Find(sql);}}} View Code  转载于:https://www.cnblogs.com/zhanhengzong/p/3718533.html
http://www.huolong8.cn/news/219307/

相关文章:

  • 南昌网站建设服务平台淄博网站制作营销
  • h5网站显示的图标怎么做中国哪里在大建设
  • 郑州做网站经开区免费php源码资源网
  • 有专业做网站的吗gre考哈尔滨建设网站制作
  • 晋城 网站建设asp网站如何建设
  • 摄影网站建设的论文如何做贴吧类网站多钱
  • 南通网站建设规划目前网站开发语言
  • 沂源网站建设yx718wordpress的密码忘记
  • 建网站多少钱合适社交媒体市场营销
  • 网站制作新报价正规的营销型网站建设公司
  • 企业网站怎么做的好看如何做品牌营销策划
  • 关于做网站的书籍织梦修改网站背景颜色
  • 简历在线制作网站免费杭州市城乡规划局建设局官方网站
  • 许昌企业网站去哪开发免费推广网站翻译英文
  • 青岛开发区网站建设多少钱4399电脑版网页在线玩
  • 红河蒙自网站开发wordpress aj提交评论
  • 电影网站要怎样做才有出路百度2022年版本下载
  • 苏州建设交通高等职业技术学校网站html模板框架
  • 免费的招聘网站花果园营销型网站建设
  • 怎么做点击图片跳转网站软件制作权
  • 营销型建设网站公司做外贸比较好得网站
  • 建个购物网站市场营销网站
  • 执业医师变更注册网站中国摄影师个人网站设计
  • 套系网站怎么做ps怎么做网站模板
  • 中山网站建设方案天津低价做网站
  • 做算法题的 网站wordpress中文修改
  • 做网站需要什么手续wordpress选项下拉
  • 什么是网络设计?seo如何优化网站步骤
  • 网站服务器和空间有什么区别wordpress文章链接怎么改
  • 网站开发的技术风险大连中国建筑装饰网