续上回
CrazyCoder自动生成实体类的例子http://www.crazycoder.cn/crazycoder/Article10884.html
/// 将对象反序列化
///
/// 源对象的路径
///
public static TopicsInfo DeSerialize(string path)
{
try
{
FileStream fs = new FileStream(path, FileMode.Open);
BinaryFormatter formatter = new BinaryFormatter();
TopicsInfo objTopicsInfo = (TopicsInfo)formatter.Deserialize(fs);
fs.Close();
fs.Dispose();
return objTopicsInfo;
}
catch
{
return null;
}
}
#endregion
#region 字符串序列化
///
/// 将对象转化为以逗号分割的字符串列表,类似序列化
///
///
public string ToSplitString()
{
StringBuilder sb = new StringBuilder();
sb.Append(_tableName);
sb.Append(",");
sb.Append(this._tid);
sb.Append(",");
sb.Append(this._fid);
sb.Append(",");
sb.Append(this._iconid);
sb.Append(",");
sb.Append(this._typeid);
sb.Append(",");
sb.Append(this._readperm);
sb.Append(",");
sb.Append(this._price);
sb.Append(",");
sb.Append(this._poster);
sb.Append(",");
sb.Append(this._posterid);
sb.Append(",");
sb.Append(this._title);
sb.Append(",");
sb.Append(this._postdatetime);
sb.Append(",");
sb.Append(this._lastpost);
sb.Append(",");
sb.Append(this._lastpostid);
sb.Append(",");
sb.Append(this._lastposter);
sb.Append(",");
sb.Append(this._lastposterid);
sb.Append(",");
sb.Append(this._views);
sb.Append(",");
sb.Append(this._replies);
sb.Append(",");
sb.Append(this._displayorder);
sb.Append(",");
sb.Append(this._highlight);
sb.Append(",");
sb.Append(this._digest);
sb.Append(",");
sb.Append(this._rate);
sb.Append(",");
sb.Append(this._hide);
sb.Append(",");
sb.Append(this._poll);
sb.Append(",");
sb.Append(this._attachment);
sb.Append(",");
sb.Append(this._moderated);
sb.Append(",");
sb.Append(this._closed);
sb.Append(",");
sb.Append(this._magic);
sb.Append(",");
sb.Append(this._identify);
sb.Append(",");
sb.Append(this._special);
return sb.ToString();
}
///
/// 从字符串中初始化对象,类似反序列化
///
/// 对象字符串
public void FormSplitString(string objString)
{
if (objString == null)
{
return;
}
string[] objs = objString.Split(Convert.ToChar(","));
if (objs.Length != 29)
{
return;
}
if (objs[1] != null || objs[1].Length >= 1)
{
this._tid = System.Int32.Parse(objs[1]);
}
if (objs[2] != null || objs[2].Length >= 1)
{
this._fid = System.Int16.Parse(objs[2]);
}
if (objs[3] != null || objs[3].Length >= 1)
{
this._iconid = System.Byte.Parse(objs[3]);
}
if (objs[4] != null || objs[4].Length >= 1)
{
this._typeid = System.Int32.Parse(objs[4]);
}
if (objs[5] != null || objs[5].Length >= 1)
{
this._readperm = System.Int32.Parse(objs[5]);
}
if (objs[6] != null || objs[6].Length >= 1)
{
this._price = System.Int16.Parse(objs[6]);
}
if (objs[7] != null || objs[7].Length >= 1)
{
this._poster = objs[7];
}
if (objs[8] != null || objs[8].Length >= 1)
{
this._posterid = System.Int32.Parse(objs[8]);
}
if (objs[9] != null || objs[9].Length >= 1)
{
this._title = objs[9];
}
if (objs[10] != null || objs[10].Length >= 1)
{
this._postdatetime = System.DateTime.Parse(objs[10]);
}
if (objs[11] != null || objs[11].Length >= 1)
{
this._lastpost = System.DateTime.Parse(objs[11]);
}
if (objs[12] != null || objs[12].Length >= 1)
{
this._lastpostid = System.Int32.Parse(objs[12]);
}
if (objs[13] != null || objs[13].Length >= 1)
{
this._lastposter = objs[13];
}
if (objs[14] != null || objs[14].Length >= 1)
{
this._lastposterid = System.Int32.Parse(objs[14]);
}
if (objs[15] != null || objs[15].Length >= 1)
{
this._views = System.Int32.Parse(objs[15]);
}
if (objs[16] != null || objs[16].Length >= 1)
{
this._replies = System.Int32.Parse(objs[16]);
}
if (objs[17] != null || objs[17].Length >= 1)
{
this._displayorder = System.Int32.Parse(objs[17]);
}
if (objs[18] != null || objs[18].Length >= 1)
{
this._highlight = objs[18];
}
if (objs[19] != null || objs[19].Length >= 1)
{
this._digest = System.Byte.Parse(objs[19]);
}
if (objs[20] != null || objs[20].Length >= 1)
{
this._rate = System.Int32.Parse(objs[20]);
}
if (objs[21] != null || objs[21].Length >= 1)
{
this._hide = System.Int32.Parse(objs[21]);
}
if (objs[22] != null || objs[22].Length >= 1)
{
this._poll = System.Int32.Parse(objs[22]);
}
if (objs[23] != null || objs[23].Length >= 1)
{
this._attachment = System.Int32.Parse(objs[23]);
}
if (objs[24] != null || objs[24].Length >= 1)
{
this._moderated = System.Byte.Parse(objs[24]);
}
if (objs[25] != null || objs[25].Length >= 1)
{
this._closed = System.Int32.Parse(objs[25]);
}
if (objs[26] != null || objs[26].Length >= 1)
{
this._magic = System.Int32.Parse(objs[26]);
}
if (objs[27] != null || objs[27].Length >= 1)
{
this._identify = System.Int32.Parse(objs[27]);
}
if (objs[28] != null || objs[28].Length >= 1)
{
this._special = System.Byte.Parse(objs[28]);
}
}
#endregion
#region 将对象转化为Url连接字符串 string ToUrlEncodeLinkString()
///
/// 将对象转化为Url连接字符串
///
///
public string ToUrlEncodeLinkString()
{
System.Text.StringBuilder sbStr = new System.Text.StringBuilder(1024);
sbStr.Append("&Tid=").Append(System.Web.HttpUtility.UrlEncode(this._tid.ToString()));
sbStr.Append("&Fid=").Append(System.Web.HttpUtility.UrlEncode(this._fid.ToString()));
sbStr.Append("&Iconid=").Append(System.Web.HttpUtility.UrlEncode(this._iconid.ToString()));
sbStr.Append("&Typeid=").Append(System.Web.HttpUtility.UrlEncode(this._typeid.ToString()));
sbStr.Append("&Readperm=").Append(System.Web.HttpUtility.UrlEncode(this._readperm.ToString()));
sbStr.Append("&Price=").Append(System.Web.HttpUtility.UrlEncode(this._price.ToString()));
if (!string.IsNullOrEmpty(this._poster))
{
sbStr.Append("&Poster=").Append(System.Web.HttpUtility.UrlEncode(this._poster));
}
sbStr.Append("&Posterid=").Append(System.Web.HttpUtility.UrlEncode(this._posterid.ToString()));
if (!string.IsNullOrEmpty(this._title))
{
sbStr.Append("&Title=").Append(System.Web.HttpUtility.UrlEncode(this._title));
}
sbStr.Append("&Postdatetime=").Append(System.Web.HttpUtility.UrlEncode(this._postdatetime.ToString()));
sbStr.Append("&Lastpost=").Append(System.Web.HttpUtility.UrlEncode(this._lastpost.ToString()));
sbStr.Append("&Lastpostid=").Append(System.Web.HttpUtility.UrlEncode(this._lastpostid.ToString()));
if (!string.IsNullOrEmpty(this._lastposter))
{
sbStr.Append("&Lastposter=").Append(System.Web.HttpUtility.UrlEncode(this._lastposter));
}
sbStr.Append("&Lastposterid=").Append(System.Web.HttpUtility.UrlEncode(this._lastposterid.ToString()));
sbStr.Append("&Views=").Append(System.Web.HttpUtility.UrlEncode(this._views.ToString()));
sbStr.Append("&Replies=").Append(System.Web.HttpUtility.UrlEncode(this._replies.ToString()));
sbStr.Append("&Displayorder=").Append(System.Web.HttpUtility.UrlEncode(this._displayorder.ToString()));
if (!string.IsNullOrEmpty(this._highlight))
{
sbStr.Append("&Highlight=").Append(System.Web.HttpUtility.UrlEncode(this._highlight));
}
sbStr.Append("&Digest=").Append(System.Web.HttpUtility.UrlEncode(this._digest.ToString()));
sbStr.Append("&Rate=").Append(System.Web.HttpUtility.UrlEncode(this._rate.ToString()));
sbStr.Append("&Hide=").Append(System.Web.HttpUtility.UrlEncode(this._hide.ToString()));
sbStr.Append("&Poll=").Append(System.Web.HttpUtility.UrlEncode(this._poll.ToString()));
sbStr.Append("&Attachment=").Append(System.Web.HttpUtility.UrlEncode(this._attachment.ToString()));
sbStr.Append("&Moderated=").Append(System.Web.HttpUtility.UrlEncode(this._moderated.ToString()));
sbStr.Append("&Closed=").Append(System.Web.HttpUtility.UrlEncode(this._closed.ToString()));
sbStr.Append("&Magic=").Append(System.Web.HttpUtility.UrlEncode(this._magic.ToString()));
sbStr.Append("&Identify=").Append(System.Web.HttpUtility.UrlEncode(this._identify.ToString()));
sbStr.Append("&Special=").Append(System.Web.HttpUtility.UrlEncode(this._special.ToString()));
return sbStr.ToString();
}
#endregion
#region 将对象转化为Url Javascript格式的Escape连接字符串 string ToUrlEscapeString()
///
/// 将对象转化为Url连接字符串
///
///
public string ToUrlEscapeString()
{
System.Text.StringBuilder sbStr = new System.Text.StringBuilder(1024);
sbStr.Append("&Tid=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._tid.ToString()));
sbStr.Append("&Fid=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._fid.ToString()));
sbStr.Append("&Iconid=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._iconid.ToString()));
sbStr.Append("&Typeid=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._typeid.ToString()));
sbStr.Append("&Readperm=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._readperm.ToString()));
sbStr.Append("&Price=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._price.ToString()));
if (!string.IsNullOrEmpty(this._poster))
{
sbStr.Append("&Poster=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._poster));
}
sbStr.Append("&Posterid=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._posterid.ToString()));
if (!string.IsNullOrEmpty(this._title))
{
sbStr.Append("&Title=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._title));
}
sbStr.Append("&Postdatetime=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._postdatetime.ToString()));
sbStr.Append("&Lastpost=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._lastpost.ToString()));
sbStr.Append("&Lastpostid=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._lastpostid.ToString()));
if (!string.IsNullOrEmpty(this._lastposter))
{
sbStr.Append("&Lastposter=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._lastposter));
}
sbStr.Append("&Lastposterid=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._lastposterid.ToString()));
sbStr.Append("&Views=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._views.ToString()));
sbStr.Append("&Replies=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._replies.ToString()));
sbStr.Append("&Displayorder=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._displayorder.ToString()));
if (!string.IsNullOrEmpty(this._highlight))
{
sbStr.Append("&Highlight=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._highlight));
}
sbStr.Append("&Digest=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._digest.ToString()));
sbStr.Append("&Rate=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._rate.ToString()));
sbStr.Append("&Hide=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._hide.ToString()));
sbStr.Append("&Poll=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._poll.ToString()));
sbStr.Append("&Attachment=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._attachment.ToString()));
sbStr.Append("&Moderated=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._moderated.ToString()));
sbStr.Append("&Closed=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._closed.ToString()));
sbStr.Append("&Magic=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._magic.ToString()));
sbStr.Append("&Identify=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._identify.ToString()));
sbStr.Append("&Special=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._special.ToString()));
return sbStr.ToString();
}
#endregion
#region 复制对象,返回一个新对象 virtual TopicsInfo Copy()
///
/// 复制对象,返回一个新对象
///
///
public virtual TopicsInfo Copy()
{
TopicsInfo copy = new TopicsInfo();
copy.RowIndex = this.RowIndex;
copy.Tid = this.Tid;
copy.Fid = this.Fid;
copy.Iconid = this.Iconid;
copy.Typeid = this.Typeid;
copy.Readperm = this.Readperm;
copy.Price = this.Price;
copy.Poster = this.Poster;
copy.Posterid = this.Posterid;
copy.Title = this.Title;
copy.Postdatetime = this.Postdatetime;
copy.Lastpost = this.Lastpost;
copy.Lastpostid = this.Lastpostid;
copy.Lastposter = this.Lastposter;
copy.Lastposterid = this.Lastposterid;
copy.Views = this.Views;
copy.Replies = this.Replies;
copy.Displayorder = this.Displayorder;
copy.Highlight = this.Highlight;
copy.Digest = this.Digest;
copy.Rate = this.Rate;
copy.Hide = this.Hide;
copy.Poll = this.Poll;
copy.Attachment = this.Attachment;
copy.Moderated = this.Moderated;
copy.Closed = this.Closed;
copy.Magic = this.Magic;
copy.Identify = this.Identify;
copy.Special = this.Special;
return copy;
}
#endregion
#region 返回两个对象是否相等 virtual bool Equals(TopicsInfo toObject static bool Equals(TopicsInfo Object1, TopicsInfo Object2)
///
/// 返回是否与指定对象相等
///
///
///
public virtual bool Equals(TopicsInfo toObject)
{
if (toObject == null)
return false;
return Equals(this, toObject);
}
///
/// 判断两个对象是否相等
///
///TopicsInfo实体
///TopicsInfo实体
///
public static bool Equals(TopicsInfo Object1, TopicsInfo Object2)
{
if (Object1 == null && Object2 == null)
return true;
if (Object1 == null ^ Object2 == null)
return false;
bool equal = true;
if (Object1.Tid != Object2.Tid)
return false;
if (Object1.Fid != Object2.Fid)
return false;
if (Object1.Iconid != Object2.Iconid)
return false;
if (Object1.Typeid != Object2.Typeid)
return false;
if (Object1.Readperm != Object2.Readperm)
return false;
if (Object1.Price != Object2.Price)
return false;
if (Object1.Poster != null && Object2.Poster != null)
{
if (Object1.Poster != Object2.Poster)
return false;
}
else if (Object1.Poster == null ^ Object2.Poster == null)
{
return false;
}
if (Object1.Posterid != Object2.Posterid)
return false;
if (Object1.Title != null && Object2.Title != null)
{
if (Object1.Title != Object2.Title)
return false;
}
else if (Object1.Title == null ^ Object2.Title == null)
{
return false;
}
if (Object1.Postdatetime != Object2.Postdatetime)
return false;
if (Object1.Lastpost != Object2.Lastpost)
return false;
if (Object1.Lastpostid != Object2.Lastpostid)
return false;
if (Object1.Lastposter != null && Object2.Lastposter != null)
{
if (Object1.Lastposter != Object2.Lastposter)
return false;
}
else if (Object1.Lastposter == null ^ Object2.Lastposter == null)
{
return false;
}
if (Object1.Lastposterid != Object2.Lastposterid)
return false;
if (Object1.Views != Object2.Views)
return false;
if (Object1.Replies != Object2.Replies)
return false;
if (Object1.Displayorder != Object2.Displayorder)
return false;
if (Object1.Highlight != null && Object2.Highlight != null)
{
if (Object1.Highlight != Object2.Highlight)
return false;
}
else if (Object1.Highlight == null ^ Object2.Highlight == null)
{
return false;
}
if (Object1.Digest != Object2.Digest)
return false;
if (Object1.Rate != Object2.Rate)
return false;
if (Object1.Hide != Object2.Hide)
return false;
if (Object1.Poll != Object2.Poll)
return false;
if (Object1.Attachment != Object2.Attachment)
return false;
if (Object1.Moderated != Object2.Moderated)
return false;
if (Object1.Closed != Object2.Closed)
return false;
if (Object1.Magic != Object2.Magic)
return false;
if (Object1.Identify != Object2.Identify)
return false;
if (Object1.Special != Object2.Special)
return false;
return equal;
}
#endregion
#region 返回实体数据表字段的Xml Map ToDataEntitiesMap()
///
/// 返回实体数据表字段的Xml Map
///
///
public static string ToDataEntitiesMap()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("\n");
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append(" \n");
sb.Append("\n");
return sb.ToString();
}
#endregion
#region ToXml 返回存储在实体类中的Xml表现形式
///
/// 返回存储在实体类中的Xml表现形式
///
///
public string ToXml()
{
System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(TopicsInfo), "http://www.crazycoder.cn/coder/entitiesnamespace");
MemoryStream stream = new MemoryStream();
System.Xml.XmlWriterSettings setting = new System.Xml.XmlWriterSettings();
setting.Encoding = new UTF8Encoding(false);
setting.Indent = true;
using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(stream, setting))
{
xs.Serialize(writer, this);
}
return Encoding.UTF8.GetString(stream.ToArray());
}
#endregion
#region FromXml 从Xml字符串中反序列化获得实体类
///
/// 从Xml字符串中反序列化获得实体类
///
/// Xml
///
public static TopicsInfo FromXml(string xml)
{
return FromXml(xml, System.Text.Encoding.UTF8);
}
///
/// 从Xml字符串中反序列化获得实体类
///
/// Xml
///
public static TopicsInfo FromXml(string xml, System.Text.Encoding encoding)
{
byte[] bt = encoding.GetBytes(xml);
System.IO.Stream sm = (System.IO.Stream)new System.IO.MemoryStream(bt);
System.IO.TextReader tr = new System.IO.StreamReader(sm);
System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(TopicsInfo));
TopicsInfo obj = (TopicsInfo)ser.Deserialize(tr);
tr.Close();
sm.Close();
return obj;
}
#endregion
#region 获取哈希值 override int GetHashCode()
///
/// 获取哈希值
///
///
public override int GetHashCode()
{
return this.Tid.GetHashCode() ^
this.Fid.GetHashCode() ^
this.Iconid.GetHashCode() ^
this.Typeid.GetHashCode() ^
this.Readperm.GetHashCode() ^
this.Price.GetHashCode() ^
((this.Poster == null) ? string.Empty : this.Poster).GetHashCode() ^
this.Posterid.GetHashCode() ^
((this.Title == null) ? string.Empty : this.Title).GetHashCode() ^
this.Postdatetime.GetHashCode() ^
this.Lastpost.GetHashCode() ^
this.Lastpostid.GetHashCode() ^
((this.Lastposter == null) ? string.Empty : this.Lastposter).GetHashCode() ^
this.Lastposterid.GetHashCode() ^
this.Views.GetHashCode() ^
this.Replies.GetHashCode() ^
this.Displayorder.GetHashCode() ^
((this.Highlight == null) ? string.Empty : this.Highlight).GetHashCode() ^
this.Digest.GetHashCode() ^
this.Rate.GetHashCode() ^
this.Hide.GetHashCode() ^
this.Poll.GetHashCode() ^
this.Attachment.GetHashCode() ^
this.Moderated.GetHashCode() ^
this.Closed.GetHashCode() ^
this.Magic.GetHashCode() ^
this.Identify.GetHashCode() ^
this.Special.GetHashCode();
}
#endregion
#region 输出表定义的Sql语句 static string ToTableSql()
///
/// 输出表定义的Sql语句
///
///
public static string ToTableSql()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("if exists (select 1\n");
sb.Append(" from sysobjects\n");
sb.Append(" where id = object_id('dbo.Forum_Topics')\n");
sb.Append(" and type = 'U')\n");
sb.Append(" drop table dbo.Forum_Topics\n");
sb.Append("go\n");
sb.Append("/*==============================================================*/\n");
sb.Append("/* Table: Forum_Topics */\n");
sb.Append("/* 创建人: */\n");
sb.Append("/* 创建时间: 星期四, 2008年9月11日 */\n");
sb.Append("/*==============================================================*/\n");
sb.Append("create table dbo.[Forum_Topics] (\n");
sb.Append(" [tid] int NOT NULL identity,\n");
sb.Append(" [fid] smallint NOT NULL ,\n");
sb.Append(" [iconid] tinyint NOT NULL default ((0)) ,\n");
sb.Append(" [typeid] int NOT NULL default ((0)) ,\n");
sb.Append(" [readperm] int NOT NULL default ((0)) ,\n");
sb.Append(" [price] smallint NOT NULL default ((0)) ,\n");
sb.Append(" [poster] nchar(20) NOT NULL default ('') ,\n");
sb.Append(" [posterid] int NOT NULL default ((0)) ,\n");
sb.Append(" [title] nchar(60) NOT NULL ,\n");
sb.Append(" [postdatetime] datetime NOT NULL default (getdate()) ,\n");
sb.Append(" [lastpost] datetime NOT NULL default (getdate()) ,\n");
sb.Append(" [lastpostid] int NOT NULL default ((0)) ,\n");
sb.Append(" [lastposter] nchar(20) NOT NULL default ('') ,\n");
sb.Append(" [lastposterid] int NOT NULL default ((0)) ,\n");
sb.Append(" [views] int NOT NULL default ((0)) ,\n");
sb.Append(" [replies] int NOT NULL default ((0)) ,\n");
sb.Append(" [displayorder] int NOT NULL default ((0)) ,\n");
sb.Append(" [highlight] varchar(500) NOT NULL default ('') ,\n");
sb.Append(" [digest] tinyint NOT NULL default ((0)) ,\n");
sb.Append(" [rate] int NOT NULL default ((0)) ,\n");
sb.Append(" [hide] int NOT NULL default ((0)) ,\n");
sb.Append(" [poll] int NOT NULL default ((0)) ,\n");
sb.Append(" [attachment] int NOT NULL default ((0)) ,\n");
sb.Append(" [moderated] tinyint NOT NULL default ((0)) ,\n");
sb.Append(" [closed] int NOT NULL default ((0)) ,\n");
sb.Append(" [magic] int NOT NULL default ((0)) ,\n");
sb.Append(" [identify] int NOT NULL default ('0') ,\n");
sb.Append(" [special] tinyint NOT NULL default ((0)) ,\n");
sb.Append(" constraint PK_FORUM_TOPICS primary key (tid)\n");
sb.Append(")\n");
sb.Append("go\n");
return sb.ToString();
}
#endregion
}
#region 实体接口类
///
/// 数据表Forum_Topics 的实体类 TopicsInfo 的接口
///
public partial interface ITopicsInfo : IDataEntities
{
#region 属性
///
///
///
System.Int32 Tid{ get; set; }
///
///
///
System.Int16 Fid{ get; set; }
///
///
///
System.Byte Iconid{ get; set; }
///
///
///
System.Int32 Typeid{ get; set; }
///
///
///
System.Int32 Readperm{ get; set; }
///
///
///
System.Int16 Price{ get; set; }
///
///
///
System.String Poster{ get; set; }
///
///
///
System.Int32 Posterid{ get; set; }
///
///
///
System.String Title{ get; set; }
///
///
///
System.DateTime Postdatetime{ get; set; }
///
///
///
System.DateTime Lastpost{ get; set; }
///
///
///
System.Int32 Lastpostid{ get; set; }
///
///
///
System.String Lastposter{ get; set; }
///
///
///
System.Int32 Lastposterid{ get; set; }
///
///
///
System.Int32 Views{ get; set; }
///
///
///
System.Int32 Replies{ get; set; }
///
///
///
System.Int32 Displayorder{ get; set; }
///
///
///
System.String Highlight{ get; set; }
///
///
///
System.Byte Digest{ get; set; }
///
///
///
System.Int32 Rate{ get; set; }
///
///
///
System.Int32 Hide{ get; set; }
///
///
///
System.Int32 Poll{ get; set; }
///
///
///
System.Int32 Attachment{ get; set; }
///
///
///
System.Byte Moderated{ get; set; }
///
///
///
System.Int32 Closed{ get; set; }
///
///
///
System.Int32 Magic{ get; set; }
///
///
///
System.Int32 Identify{ get; set; }
///
///
///
System.Byte Special{ get; set; }
#endregion
#region 方法
/// 复制对象,返回一个新对象
///
///
TopicsInfo Copy();
///
/// 返回两个对象是否相等
///
///
///
bool Equals(TopicsInfo toObject);
#endregion
}
#endregion
#region 表 的字段枚举
///
/// 表Forum_Topics的字段枚举
///
public enum TopicsInfoEnumeration
{
///
/// 默认属性,表示未知属性 枚举值为0
///
Undefined = 0,
///
/// Tid : 1
///
[EnumTextValue("Tid")]
[ColumnEnum("Tid", typeof(System.Int32), System.Data.DbType.Int32, true, true, false, true,4)]
Tid = 1,
///
/// Fid : 2
///
[EnumTextValue("Fid")]
[ColumnEnum("Fid", typeof(System.Int16), System.Data.DbType.Int16, false, false, false, false,2)]
Fid = 2,
///
/// Iconid : 3
///
[EnumTextValue("Iconid")]
[ColumnEnum("Iconid", typeof(System.Byte), System.Data.DbType.Byte, false, false, false, false,1)]
Iconid = 3,
///
/// Typeid : 4
///
[EnumTextValue("Typeid")]
[ColumnEnum("Typeid", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Typeid = 4,
///
/// Readperm : 5
///
[EnumTextValue("Readperm")]
[ColumnEnum("Readperm", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Readperm = 5,
///
/// Price : 6
///
[EnumTextValue("Price")]
[ColumnEnum("Price", typeof(System.Int16), System.Data.DbType.Int16, false, false, false, false,2)]
Price = 6,
///
/// Poster : 7
///
[EnumTextValue("Poster")]
[ColumnEnum("Poster", typeof(System.String), System.Data.DbType.StringFixedLength, false, false, false, false,20)]
Poster = 7,
///
/// Posterid : 8
///
[EnumTextValue("Posterid")]
[ColumnEnum("Posterid", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Posterid = 8,
///
/// Title : 9
///
[EnumTextValue("Title")]
[ColumnEnum("Title", typeof(System.String), System.Data.DbType.StringFixedLength, false, false, false, false,60)]
Title = 9,
///
/// Postdatetime : 10
///
[EnumTextValue("Postdatetime")]
[ColumnEnum("Postdatetime", typeof(System.DateTime), System.Data.DbType.DateTime, false, false, false, false,8)]
Postdatetime = 10,
///
/// Lastpost : 11
///
[EnumTextValue("Lastpost")]
[ColumnEnum("Lastpost", typeof(System.DateTime), System.Data.DbType.DateTime, false, false, false, false,8)]
Lastpost = 11,
///
/// Lastpostid : 12
///
[EnumTextValue("Lastpostid")]
[ColumnEnum("Lastpostid", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Lastpostid = 12,
///
/// Lastposter : 13
///
[EnumTextValue("Lastposter")]
[ColumnEnum("Lastposter", typeof(System.String), System.Data.DbType.StringFixedLength, false, false, false, false,20)]
Lastposter = 13,
///
/// Lastposterid : 14
///
[EnumTextValue("Lastposterid")]
[ColumnEnum("Lastposterid", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Lastposterid = 14,
///
/// Views : 15
///
[EnumTextValue("Views")]
[ColumnEnum("Views", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Views = 15,
///
/// Replies : 16
///
[EnumTextValue("Replies")]
[ColumnEnum("Replies", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Replies = 16,
///
/// Displayorder : 17
///
[EnumTextValue("Displayorder")]
[ColumnEnum("Displayorder", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Displayorder = 17,
///
/// Highlight : 18
///
[EnumTextValue("Highlight")]
[ColumnEnum("Highlight", typeof(System.String), System.Data.DbType.AnsiString, false, false, false, false,500)]
Highlight = 18,
///
/// Digest : 19
///
[EnumTextValue("Digest")]
[ColumnEnum("Digest", typeof(System.Byte), System.Data.DbType.Byte, false, false, false, false,1)]
Digest = 19,
///
/// Rate : 20
///
[EnumTextValue("Rate")]
[ColumnEnum("Rate", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Rate = 20,
///
/// Hide : 21
///
[EnumTextValue("Hide")]
[ColumnEnum("Hide", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Hide = 21,
///
/// Poll : 22
///
[EnumTextValue("Poll")]
[ColumnEnum("Poll", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Poll = 22,
///
/// Attachment : 23
///
[EnumTextValue("Attachment")]
[ColumnEnum("Attachment", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Attachment = 23,
///
/// Moderated : 24
///
[EnumTextValue("Moderated")]
[ColumnEnum("Moderated", typeof(System.Byte), System.Data.DbType.Byte, false, false, false, false,1)]
Moderated = 24,
///
/// Closed : 25
///
[EnumTextValue("Closed")]
[ColumnEnum("Closed", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Closed = 25,
///
/// Magic : 26
///
[EnumTextValue("Magic")]
[ColumnEnum("Magic", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Magic = 26,
///
/// Identify : 27
///
[EnumTextValue("Identify")]
[ColumnEnum("Identify", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
Identify = 27,
///
/// Special : 28
///
[EnumTextValue("Special")]
[ColumnEnum("Special", typeof(System.Byte), System.Data.DbType.Byte, false, false, false, false,1)]
Special = 28
}
#endregion
#region 比较规则
///
/// TopicsInfo的比较规则
///
public partial class TopicsInfoCompare
{
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Tid(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Tid > obj2.Tid)
{
return 1;
}
else if (obj1.Tid == obj2.Tid)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Fid(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Fid > obj2.Fid)
{
return 1;
}
else if (obj1.Fid == obj2.Fid)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Iconid(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Iconid > obj2.Iconid)
{
return 1;
}
else if (obj1.Iconid == obj2.Iconid)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Typeid(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Typeid > obj2.Typeid)
{
return 1;
}
else if (obj1.Typeid == obj2.Typeid)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Readperm(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Readperm > obj2.Readperm)
{
return 1;
}
else if (obj1.Readperm == obj2.Readperm)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Price(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Price > obj2.Price)
{
return 1;
}
else if (obj1.Price == obj2.Price)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Poster(TopicsInfo obj1,TopicsInfo obj2)
{
return System.Collections.Comparer.Default.Compare(obj1.Poster, obj2.Poster);
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Posterid(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Posterid > obj2.Posterid)
{
return 1;
}
else if (obj1.Posterid == obj2.Posterid)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Title(TopicsInfo obj1,TopicsInfo obj2)
{
return System.Collections.Comparer.Default.Compare(obj1.Title, obj2.Title);
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Postdatetime(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Postdatetime > obj2.Postdatetime)
{
return 1;
}
else if (obj1.Postdatetime == obj2.Postdatetime)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Lastpost(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Lastpost > obj2.Lastpost)
{
return 1;
}
else if (obj1.Lastpost == obj2.Lastpost)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Lastpostid(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Lastpostid > obj2.Lastpostid)
{
return 1;
}
else if (obj1.Lastpostid == obj2.Lastpostid)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Lastposter(TopicsInfo obj1,TopicsInfo obj2)
{
return System.Collections.Comparer.Default.Compare(obj1.Lastposter, obj2.Lastposter);
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Lastposterid(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Lastposterid > obj2.Lastposterid)
{
return 1;
}
else if (obj1.Lastposterid == obj2.Lastposterid)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Views(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Views > obj2.Views)
{
return 1;
}
else if (obj1.Views == obj2.Views)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Replies(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Replies > obj2.Replies)
{
return 1;
}
else if (obj1.Replies == obj2.Replies)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Displayorder(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Displayorder > obj2.Displayorder)
{
return 1;
}
else if (obj1.Displayorder == obj2.Displayorder)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Highlight(TopicsInfo obj1,TopicsInfo obj2)
{
return System.Collections.Comparer.Default.Compare(obj1.Highlight, obj2.Highlight);
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Digest(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Digest > obj2.Digest)
{
return 1;
}
else if (obj1.Digest == obj2.Digest)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Rate(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Rate > obj2.Rate)
{
return 1;
}
else if (obj1.Rate == obj2.Rate)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Hide(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Hide > obj2.Hide)
{
return 1;
}
else if (obj1.Hide == obj2.Hide)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Poll(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Poll > obj2.Poll)
{
return 1;
}
else if (obj1.Poll == obj2.Poll)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Attachment(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Attachment > obj2.Attachment)
{
return 1;
}
else if (obj1.Attachment == obj2.Attachment)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Moderated(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Moderated > obj2.Moderated)
{
return 1;
}
else if (obj1.Moderated == obj2.Moderated)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Closed(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Closed > obj2.Closed)
{
return 1;
}
else if (obj1.Closed == obj2.Closed)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Magic(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Magic > obj2.Magic)
{
return 1;
}
else if (obj1.Magic == obj2.Magic)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Identify(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Identify > obj2.Identify)
{
return 1;
}
else if (obj1.Identify == obj2.Identify)
{
return 0;
}
else
{
return -1;
}
}
///
/// 根据 统计
///
/// 对象
/// 对象
///
public static int Special(TopicsInfo obj1,TopicsInfo obj2)
{
if (obj1.Special > obj2.Special)
{
return 1;
}
else if (obj1.Special == obj2.Special)
{
return 0;
}
else
{
return -1;
}
}
}
#endregion
#region 强类型实体基类 TopicsInfoCollection
///
/// TopicsInfo强类型实体集合
///
[Serializable]
public partial class TopicsInfoCollection : TList
{
#region ExportExcelXml 导出到EXCEL
///
/// 输入列表为Excel的Xml文件
///
///
public string ExportExcelXml()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder(1024);
#region 头文件
sb.Append("\n");
sb.Append("\n");
sb.Append(" sb.Append(" xmlns:o=\"urn:schemas-microsoft-com:office:office\"\n"); sb.Append(" xmlns:x=\"urn:schemas-microsoft-com:office:excel\"\n"); sb.Append(" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"\n"); sb.Append(" xmlns:html=\"http://www.w3.org/TR/REC-html40\">\n"); sb.Append(" sb.Append(" sb.Append(" sb.Append(" sb.Append(" sb.Append(" sb.Append(" \n"); sb.Append(" sb.Append(" sb.Append(" sb.Append(" sb.Append(" sb.Append(" sb.Append(" sb.Append(" \n"); sb.Append(" sb.Append(" \n"); sb.Append(" \n"); sb.Append(" sb.Append(" sb.Append(" x:FullRows=\"1\" ss:DefaultColumnWidth=\"54\" ss:DefaultRowHeight=\"14.25\">\n"); #endregion sb.Append(" #region 标题 //Tid sb.Append(" //Fid sb.Append(" //Iconid sb.Append(" //Typeid sb.Append(" //Readperm sb.Append(" //Price sb.Append(" //Poster sb.Append(" //Posterid sb.Append(" //Title sb.Append(" //Postdatetime sb.Append(" //Lastpost sb.Append(" //Lastpostid sb.Append(" //Lastposter sb.Append(" //Lastposterid sb.Append(" //Views sb.Append(" //Replies sb.Append(" //Displayorder sb.Append(" //Highlight sb.Append(" //Digest sb.Append(" //Rate sb.Append(" //Hide sb.Append(" //Poll sb.Append(" //Attachment sb.Append(" //Moderated sb.Append(" //Closed sb.Append(" //Magic sb.Append(" //Identify sb.Append(" //Special sb.Append(" #endregion sb.Append(" \n"); foreach (TopicsInfo obj in this) { sb.Append(" #region 内容 //Tid sb.Append(" sb.Append(obj.Tid); sb.Append("\n"); //Fid sb.Append(" sb.Append(obj.Fid); sb.Append("\n"); //Iconid sb.Append(" sb.Append(obj.Iconid); sb.Append("\n"); //Typeid sb.Append(" sb.Append(obj.Typeid); sb.Append("\n"); //Readperm sb.Append(" sb.Append(obj.Readperm); sb.Append("\n"); //Price sb.Append(" sb.Append(obj.Price); sb.Append("\n"); //Poster sb.Append(" sb.Append(string.IsNullOrEmpty(obj.Poster) ? "" : obj.Poster.Replace(">", ">").Replace("<", "<")); sb.Append("\n"); //Posterid sb.Append(" sb.Append(obj.Posterid); sb.Append("\n"); //Title sb.Append(" sb.Append(string.IsNullOrEmpty(obj.Title) ? "" : obj.Title.Replace(">", ">").Replace("<", "<")); sb.Append("\n"); //Postdatetime sb.Append(" sb.Append(obj.Postdatetime); sb.Append("\n"); //Lastpost sb.Append(" sb.Append(obj.Lastpost); sb.Append("\n"); //Lastpostid sb.Append(" sb.Append(obj.Lastpostid); sb.Append("\n"); //Lastposter sb.Append(" sb.Append(string.IsNullOrEmpty(obj.Lastposter) ? "" : obj.Lastposter.Replace(">", ">").Replace("<", "<")); sb.Append("\n"); //Lastposterid sb.Append(" sb.Append(obj.Lastposterid); sb.Append("\n"); //Views sb.Append(" sb.Append(obj.Views); sb.Append("\n"); //Replies sb.Append(" sb.Append(obj.Replies); sb.Append("\n"); //Displayorder sb.Append(" sb.Append(obj.Displayorder); sb.Append("\n"); //Highlight sb.Append(" sb.Append(string.IsNullOrEmpty(obj.Highlight) ? "" : obj.Highlight.Replace(">", ">").Replace("<", "<")); sb.Append("\n"); //Digest sb.Append(" sb.Append(obj.Digest); sb.Append("\n"); //Rate sb.Append(" sb.Append(obj.Rate); sb.Append("\n"); //Hide sb.Append(" sb.Append(obj.Hide); sb.Append("\n"); //Poll sb.Append(" sb.Append(obj.Poll); sb.Append("\n"); //Attachment sb.Append(" sb.Append(obj.Attachment); sb.Append("\n"); //Moderated sb.Append(" sb.Append(obj.Moderated); sb.Append("\n"); //Closed sb.Append(" sb.Append(obj.Closed); sb.Append("\n"); //Magic sb.Append(" sb.Append(obj.Magic); sb.Append("\n"); //Identify sb.Append(" sb.Append(obj.Identify); sb.Append("\n"); //Special sb.Append(" sb.Append(obj.Special); sb.Append("\n"); #endregion sb.Append(" \n"); } sb.Append("
\n");
#region 尾文件
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append(" \n");
sb.Append(" \n");
sb.Append("
sb.Append("
sb.Append(" \n");
sb.Append(" \n");
sb.Append("\n");
#endregion
return sb.ToString();
}
#endregion
#region ToXml 返回实体类强类型列表的Xml表现形式
///
/// 返回实体类强类型列表的Xml表现形式
///
///
public string ToXml()
{
System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(TopicsInfoCollection), "http://www.crazycoder.cn/coder/entitiesnamespace");
MemoryStream stream = new MemoryStream();
System.Xml.XmlWriterSettings setting = new System.Xml.XmlWriterSettings();
setting.Encoding = new UTF8Encoding(false);
setting.Indent = true;
using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(stream, setting))
{
xs.Serialize(writer, this);
}
return Encoding.UTF8.GetString(stream.ToArray());
}
#endregion
#region FromXml 从Xml字符串中反序列化获得类
///
/// 从Xml字符串中反序列化获得类
///
/// Xml
///
public static TopicsInfoCollection FromXml(string xml)
{
return FromXml(xml, System.Text.Encoding.UTF8);
}
///
/// 从Xml字符串中反序列化获得类
///
/// Xml
///
public static TopicsInfoCollection FromXml(string xml, System.Text.Encoding encoding)
{
byte[] bt = encoding.GetBytes(xml);
System.IO.Stream sm = (System.IO.Stream)new System.IO.MemoryStream(bt);
System.IO.TextReader tr = new System.IO.StreamReader(sm);
System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(TopicsInfoCollection));
TopicsInfoCollection obj = (TopicsInfoCollection)ser.Deserialize(tr);
tr.Close();
sm.Close();
return obj;
}
#endregion
#region 创建插入的SQL语句 string ToInsertSql()
///
/// 创建插入的SQL语句
///
///
public string ToInsertSql()
{
StringBuilder sb = new StringBuilder();
foreach (TopicsInfo obj in this)
{
sb.Append("INSERT INTO [Forum_Topics]([fid],[iconid],[typeid],[readperm],[price],[poster],[posterid],[title],[postdatetime],[lastpost],[lastpostid],[lastposter],[lastposterid],[views],[replies],[displayorder],[highlight],[digest],[rate],[hide],[poll],[attachment],[moderated],[closed],[magic],[identify],[special]) \n");
sb.Append("VALUES (");
sb.Append(obj.Fid);
sb.Append(",");
sb.Append(obj.Iconid);
sb.Append(",");
sb.Append(obj.Typeid);
sb.Append(",");
sb.Append(obj.Readperm);
sb.Append(",");
sb.Append(obj.Price);
sb.Append(",");
sb.Append("'");
sb.Append(obj.Poster);
sb.Append("'");
sb.Append(",");
sb.Append(obj.Posterid);
sb.Append(",");
sb.Append("'");
sb.Append(obj.Title);
sb.Append("'");
sb.Append(",");
sb.Append("'");
sb.Append(obj.Postdatetime);
sb.Append("'");
sb.Append(",");
sb.Append("'");
sb.Append(obj.Lastpost);
sb.Append("'");
sb.Append(",");
sb.Append(obj.Lastpostid);
sb.Append(",");
sb.Append("'");
sb.Append(obj.Lastposter);
sb.Append("'");
sb.Append(",");
sb.Append(obj.Lastposterid);
sb.Append(",");
sb.Append(obj.Views);
sb.Append(",");
sb.Append(obj.Replies);
sb.Append(",");
sb.Append(obj.Displayorder);
sb.Append(",");
sb.Append("'");
sb.Append(obj.Highlight);
sb.Append("'");
sb.Append(",");
sb.Append(obj.Digest);
sb.Append(",");
sb.Append(obj.Rate);
sb.Append(",");
sb.Append(obj.Hide);
sb.Append(",");
sb.Append(obj.Poll);
sb.Append(",");
sb.Append(obj.Attachment);
sb.Append(",");
sb.Append(obj.Moderated);
sb.Append(",");
sb.Append(obj.Closed);
sb.Append(",");
sb.Append(obj.Magic);
sb.Append(",");
sb.Append(obj.Identify);
sb.Append(",");
sb.Append(obj.Special);
sb.Append(")\n");
sb.Append("Go\n");
}
return sb.ToString();
}
#endregion
#region 创建更新的SQL语句 string ToUpdateSql()
///
/// 创建更新的SQL语句
///
///
public string ToUpdateSql()
{
StringBuilder sb = new StringBuilder();
foreach (TopicsInfo obj in this)
{
sb.Append("UPDATE [Forum_Topics] Set\n");
sb.Append("fid =");
sb.Append(obj.Fid);
sb.Append(",");
sb.Append("iconid =");
sb.Append(obj.Iconid);
sb.Append(",");
sb.Append("typeid =");
sb.Append(obj.Typeid);
sb.Append(",");
sb.Append("readperm =");
sb.Append(obj.Readperm);
sb.Append(",");
sb.Append("price =");
sb.Append(obj.Price);
sb.Append(",");
sb.Append("[poster]='");
sb.Append(obj.Poster);
sb.Append("'");
sb.Append(",");
sb.Append("posterid =");
sb.Append(obj.Posterid);
sb.Append(",");
sb.Append("[title]='");
sb.Append(obj.Title);
sb.Append("'");
sb.Append(",");
sb.Append("[postdatetime]='");
sb.Append(obj.Postdatetime);
sb.Append("'");
sb.Append(",");
sb.Append("[lastpost]='");
sb.Append(obj.Lastpost);
sb.Append("'");
sb.Append(",");
sb.Append("lastpostid =");
sb.Append(obj.Lastpostid);
sb.Append(",");
sb.Append("[lastposter]='");
sb.Append(obj.Lastposter);
sb.Append("'");
sb.Append(",");
sb.Append("lastposterid =");
sb.Append(obj.Lastposterid);
sb.Append(",");
sb.Append("views =");
sb.Append(obj.Views);
sb.Append(",");
sb.Append("replies =");
sb.Append(obj.Replies);
sb.Append(",");
sb.Append("displayorder =");
sb.Append(obj.Displayorder);
sb.Append(",");
sb.Append("[highlight]='");
sb.Append(obj.Highlight);
sb.Append("'");
sb.Append(",");
sb.Append("digest =");
sb.Append(obj.Digest);
sb.Append(",");
sb.Append("rate =");
sb.Append(obj.Rate);
sb.Append(",");
sb.Append("hide =");
sb.Append(obj.Hide);
sb.Append(",");
sb.Append("poll =");
sb.Append(obj.Poll);
sb.Append(",");
sb.Append("attachment =");
sb.Append(obj.Attachment);
sb.Append(",");
sb.Append("moderated =");
sb.Append(obj.Moderated);
sb.Append(",");
sb.Append("closed =");
sb.Append(obj.Closed);
sb.Append(",");
sb.Append("magic =");
sb.Append(obj.Magic);
sb.Append(",");
sb.Append("identify =");
sb.Append(obj.Identify);
sb.Append(",");
sb.Append("special =");
sb.Append(obj.Special);
sb.Append(obj.Tid);
sb.Append("Go\n");
}
return sb.ToString();
}
#endregion
#region 序列化和反序列化 静态方法
///
/// 将对象序列化
///
/// 需要保存的路径
/// TopicsInfoCollection对象
///
public static bool Serialize(string path, TopicsInfoCollection objTopicsInfoCollection)
{
try
{
FileStream fs = new FileStream(path, FileMode.Create);
string folder = Path.GetDirectoryName(path);
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(fs, objTopicsInfoCollection);
fs.Close();
fs.Dispose();
return true;
}
catch
{
return false;
}
}
///
/// 将对象反序列化
///
/// 源对象的路径
///
public new static TopicsInfoCollection DeSerialize(string path)
{
try
{
FileStream fs = new FileStream(path, FileMode.Open);
BinaryFormatter formatter = new BinaryFormatter();
TopicsInfoCollection objTopicsInfoCollection = (TopicsInfoCollection)formatter.Deserialize(fs);
fs.Close();
fs.Dispose();
return objTopicsInfoCollection;
}
catch
{
return null;
}
}
#endregion
#region 分页 Paging
///
/// 分页
///
/// 页码
/// 页面大小
///
public TopicsInfoCollection Paging(int pageIndex, int pageSize)
{
if (pageIndex <= 0)
{
pageIndex = 1;
}
if (pageSize <= 0)
{
pageSize = 10;
}
TopicsInfoCollection list = new TopicsInfoCollection();
int recordCount = this.Length;
int startIndex = (pageIndex - 1) * pageSize;
if (startIndex > recordCount - 1)
return list;
int endIndex = pageIndex * pageSize;
if (endIndex > recordCount - 1)
endIndex = recordCount - 1;
for (int i = startIndex; i <= endIndex; i++)
{
list.Add(this[i]);
}
return list;
}
#endregion
#region 获取对象
///
/// 根据主键Tid获取TopicsInfo对象
///
/// 主键tid
///
public TopicsInfo GetByTid(System.Int32 tid)
{
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Tid == tid)
{
return objTopicsInfo;
}
}
return null;
}
///
/// 根据唯一索引Fid获取TopicsInfo对象
///
/// 唯一索引fid
///
public TopicsInfo GetByFid(System.Int16 fid)
{
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Fid == fid)
{
return objTopicsInfo;
}
}
return null;
}
#endregion
#region 根据对象枚举获取列表
///
/// 根据对象枚举TopicsInfoEnumeration获取列表
///
/// 对象数据
/// 对象列枚举
///
public TopicsInfoCollection GetList(object obj, TopicsInfoEnumeration en)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
switch (en)
{
case TopicsInfoEnumeration.Tid:
//根据Tid:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Tid == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Fid:
//根据Fid:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Fid == (System.Int16)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Iconid:
//根据Iconid:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Iconid == (System.Byte)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Typeid:
//根据Typeid:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Typeid == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Readperm:
//根据Readperm:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Readperm == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Price:
//根据Price:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Price == (System.Int16)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Poster:
//根据Poster:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Poster.Equals((System.String)obj, StringComparison.CurrentCultureIgnoreCase))
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Posterid:
//根据Posterid:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Posterid == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Title:
//根据Title:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Title.Equals((System.String)obj, StringComparison.CurrentCultureIgnoreCase))
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Postdatetime:
//根据Postdatetime:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Postdatetime == (System.DateTime)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Lastpost:
//根据Lastpost:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Lastpost == (System.DateTime)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Lastpostid:
//根据Lastpostid:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Lastpostid == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Lastposter:
//根据Lastposter:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Lastposter.Equals((System.String)obj, StringComparison.CurrentCultureIgnoreCase))
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Lastposterid:
//根据Lastposterid:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Lastposterid == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Views:
//根据Views:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Views == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Replies:
//根据Replies:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Replies == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Displayorder:
//根据Displayorder:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Displayorder == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Highlight:
//根据Highlight:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Highlight.Equals((System.String)obj, StringComparison.CurrentCultureIgnoreCase))
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Digest:
//根据Digest:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Digest == (System.Byte)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Rate:
//根据Rate:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Rate == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Hide:
//根据Hide:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Hide == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Poll:
//根据Poll:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Poll == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Attachment:
//根据Attachment:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Attachment == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Moderated:
//根据Moderated:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Moderated == (System.Byte)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Closed:
//根据Closed:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Closed == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Magic:
//根据Magic:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Magic == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Identify:
//根据Identify:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Identify == (System.Int32)obj)
{
list.Add(objTopicsInfo);
}
}
break;
case TopicsInfoEnumeration.Special:
//根据Special:取出列表
if (obj == null)
{
break;
}
else
{
if (objTopicsInfo.Special == (System.Byte)obj)
{
list.Add(objTopicsInfo);
}
}
break;
default:
break;
}
}
return list;
}
#endregion
#region 根据开始和结束位置的索引获取列表
///
/// 根据开始和结束位置的索引获取列表
///
/// 索引开始位置
/// 索引结束位置
///
public TopicsInfoCollection GetList(int startIndex, int endIndex)
{
TopicsInfoCollection list = new TopicsInfoCollection();
if (startIndex > this.Length - 1)
{
return list;
}
if (endIndex > this.Length - 1)
{
endIndex = this.Length - 1;
}
for (int i = startIndex; i <= endIndex; i++)
{
list.Add(this[i]);
}
return list;
}
#endregion
#region 根据外键获取对象列表
#endregion
#region 根据数字行列获取列表
///
/// 根据Iconid 获取TopicsInfoForum_Topics对象列表
///
/// System.Byte
///
public TopicsInfoCollection GetListByIconid(System.Byte iconid)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Iconid == iconid)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Typeid 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByTypeid(System.Int32 typeid)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Typeid == typeid)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Readperm 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByReadperm(System.Int32 readperm)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Readperm == readperm)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Price 获取TopicsInfoForum_Topics对象列表
///
/// System.Int16
///
public TopicsInfoCollection GetListByPrice(System.Int16 price)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Price == price)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Posterid 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByPosterid(System.Int32 posterid)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Posterid == posterid)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Lastpostid 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByLastpostid(System.Int32 lastpostid)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Lastpostid == lastpostid)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Lastposterid 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByLastposterid(System.Int32 lastposterid)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Lastposterid == lastposterid)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Views 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByViews(System.Int32 views)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Views == views)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Replies 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByReplies(System.Int32 replies)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Replies == replies)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Displayorder 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByDisplayorder(System.Int32 displayorder)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Displayorder == displayorder)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Digest 获取TopicsInfoForum_Topics对象列表
///
/// System.Byte
///
public TopicsInfoCollection GetListByDigest(System.Byte digest)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Digest == digest)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Rate 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByRate(System.Int32 rate)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Rate == rate)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Hide 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByHide(System.Int32 hide)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Hide == hide)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Poll 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByPoll(System.Int32 poll)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Poll == poll)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Attachment 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByAttachment(System.Int32 attachment)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Attachment == attachment)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Moderated 获取TopicsInfoForum_Topics对象列表
///
/// System.Byte
///
public TopicsInfoCollection GetListByModerated(System.Byte moderated)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Moderated == moderated)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Closed 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByClosed(System.Int32 closed)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Closed == closed)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Magic 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByMagic(System.Int32 magic)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Magic == magic)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Identify 获取TopicsInfoForum_Topics对象列表
///
/// System.Int32
///
public TopicsInfoCollection GetListByIdentify(System.Int32 identify)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Identify == identify)
{
list.Add(objTopicsInfo);
}
}
return list;
}
///
/// 根据Special 获取TopicsInfoForum_Topics对象列表
///
/// System.Byte
///
public TopicsInfoCollection GetListBySpecial(System.Byte special)
{
TopicsInfoCollection list = new TopicsInfoCollection();
foreach (TopicsInfo objTopicsInfo in this)
{
if (objTopicsInfo.Special == special)
{
list.Add(objTopicsInfo);
}
}
return list;
}
#endregion
}
#endregion
}
最新评论