疯狂代码生成器中数据构造简析

为了方便我们进行修改数据库结构而避免覆盖原有自写的代码

数据层,实体层,业务层,UI层都以Base方式的继承实现

假如我们修改了一个表的字段,我们重新生成的时候只需覆盖BASE目录相应的文件即可,而不用担心自己修正的代码被覆盖

如果我们需要重写基类的代码,我们可以直接new一个覆盖出来

例如,表名为Article

直接生成的实体层代码分为两个

1.ArticleInfoBase.cs 这里是存放代码生成生成的代码,并位于实体层的BASE目录中

2.ArticleInfo.cs这里存放实体层的代码,且ArticleInfo 是个局部类,同ArticleInfoBase一样,也就是我们把他作为了一个局部类,我们自写的代码写在这里,这样可以避免被重复覆盖的问题

其他类同

我们以一个TAG表的实体类为例,字段简单,作为实例吧

代码如下:

实体类代码,相当简单,我们修改的话直接在TagInfo.cs里修改即可

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

#region 修改日志
/*
----------------------------------------------------------------------------------------------------
-- 类创建时间: 星期日, 2008年11月30日 12:16:59
-- Created By:CrazyCoder 疯狂代码
-- 目的:表Qst_Tag的实体类 TagInfo 基类在BASE文件中
-- 表说明:标签库
-- 备注:该类以及基类所有方法由"疯狂代码"代码生成器创建 www.CrazyCoder.cn
-- mail:[email protected]
-- Msn:[email protected]
-- QQ:9095230
-- www.CrazyCoder.cn
----------------------------------------------------------------------------------------------------
*/
#endregion


namespace CrazyCoder.Entities.News
{
    /// <summary>
    /// 数据表Qst_Tag实体类 主键PK_QST_TAG 外键列表为 自增字段 TagIDInt32 唯一字段为:
    /// 基类在BASE文件包里>
    /// </summary>
    public partial class TagInfo
    {
    }


    #region 强类型实体
    /// <summary>
    /// TagInfo强类型实体集合
    /// 局部类--基类在base目录里
    /// </summary>
    public partial class TagInfoCollection
    {
           

    }
    #endregion

    #region 比较规则
    /// <summary>
    ///  TagInfo的比较规则
    /// </summary>
    public partial class TagInfoCompare
    {

    }
    #endregion

    #region 实体接口类
    /// <summary>
    /// 数据表Qst_Tag 的实体类 TagInfo 的接口 局部接口在Base文件夹中
    /// </summary>
    public partial interface ITagInfo
    {

    }

    #endregion

}
 

疯狂代码代码生成器的代码如下,这里不要懂,如果我们修改了什么字段的话可以直接覆盖,这样可以方便我们的工作效率,代码如下:

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Data;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

#region 修改日志
/*
----------------------------------------------------------------------------------------------------
-- 类创建时间: 星期日, 2008年11月30日 12:17:58
-- Created By:CrazyCoder 疯狂代码
-- 目的:表Qst_Tag的实体类TagInfo 以及实体接口 比较等
-- 表说明:标签库
-- 备注:该类以及基类所有方法由"疯狂代码"代码生成器创建 www.CrazyCoder.cn
-- mail:[email protected]
-- Msn:[email protected]
-- QQ:9095230
-- www.CrazyCoder.cn
----------------------------------------------------------------------------------------------------
*/
#endregion

namespace CrazyCoder.Entities.News
{
    /// <summary>
    /// 数据表Qst_Tag实体类基类 主键PK_QST_TAG 外键列表为 自增字段 TagIDInt32 唯一字段为:
    /// </summary>
    [Serializable]
    public partial class TagInfo : EntitiesBase,IDataEntities,ITagInfo
    {
        #region 变量
        private static string _tableName = "Qst_Tag";
        /// <summary>
        /// 实体的数据表名
        /// </summary>
        public static string TableName
        {
            get { return _tableName; }
        }
        private static string[] _tableColumns;//数据表 中的字段数组
        /// <summary>
        /// 数据表 中的字段数组
        /// </summary>
        public static string[] TableColumns
        {
            get {
                _tableColumns = new string[9]{"TagID","TagCategoryID","Name","ArticleCount","IsCommend","IsSys","IsHide","FolderName","IsDeleted"};
                return _tableColumns; }
        }
        /// <summary>
        /// 实体类
        /// </summary>
        public static string EntitiesClassName
        {
            get { return "TagInfo"; }
        }
        /// <summary>
        /// 实体类基类名
        /// </summary>
        public static string EntitiesBaseClassName
        {
            get { return "TagInfoBase"; }
        }
        #endregion

        #region 构造函数
        /// <summary>
        /// 默认构造函数 创建新的实例
        /// </summary>
        public TagInfo()
        {       
    
        }
        #region 构造函数,含所有参数

        /// <summary>
        /// 构造函数 创建新的实例
        /// </summary>
        /// <param name="_tagID"></param>
        /// <param name="_tagCategoryID">标签分类ID[GetList]</param>
        /// <param name="_name"></param>
        /// <param name="_articleCount">文章数统计[GetList]</param>
        /// <param name="_isCommend">是否推荐[GetList]</param>
        /// <param name="_isSys">是否系统定义标签[GetList]</param>
        /// <param name="_isHide">是否隐藏[GetList]</param>
        /// <param name="_folderName"></param>
        /// <param name="_isDeleted"></param>
        public TagInfo(System.Int32 _tagID,System.Int32 _tagCategoryID,System.String _name,System.Int32 _articleCount,System.Boolean _isCommend,System.Boolean _isSys,System.Boolean _isHide,System.String _folderName,System.Boolean _isDeleted)
        {
            this._tagID = _tagID;
            this._tagCategoryID = _tagCategoryID;
            this._name = _name;
            this._articleCount = _articleCount;
            this._isCommend = _isCommend;
            this._isSys = _isSys;
            this._isHide = _isHide;
            this._folderName = _folderName;
            this._isDeleted = _isDeleted;
        }
        #endregion

        #endregion

        #region 通过数据构造函数 IDataRecord DataRow DataRowView

        #region 使用只读只进的数据流的构造函数 TagInfo(IDataRecord dr)
        /// <summary>
        /// 使用只读只进的数据流的构造函数
        /// </summary>
        /// <param name="dr">只读只进的数据流</param>
        public TagInfo(IDataRecord dr)
        {
            string rowIndexName = dr.GetName(0);
            if (!string.IsNullOrEmpty(rowIndexName) && rowIndexName.ToLower() == "rowindex")
            {
                //如果返回RowIndex
                this.RowIndex = (long)dr[0];
            }
            this._tagID = dr["TagID"] == DBNull.Value ? 0 : (System.Int32)dr["TagID"]; // 数据类型int 大小4 不允许空值
            this._tagCategoryID = dr["TagCategoryID"] == DBNull.Value ? (int)0 : (System.Int32)dr["TagCategoryID"]; //标签分类ID[GetList] 数据类型int 大小4 不允许空值
            this._name = dr["Name"] == DBNull.Value ? null : (System.String)dr["Name"]; // 数据类型nvarchar 大小50 不允许空值
            this._articleCount = dr["ArticleCount"] == DBNull.Value ? (int)0 : (System.Int32)dr["ArticleCount"]; //文章数统计[GetList] 数据类型int 大小4 不允许空值
            this._isCommend = dr["IsCommend"] == DBNull.Value ? false : (System.Boolean)dr["IsCommend"]; //是否推荐[GetList] 数据类型bit 大小1 允许空值
            this._isSys = dr["IsSys"] == DBNull.Value ? false : (System.Boolean)dr["IsSys"]; //是否系统定义标签[GetList] 数据类型bit 大小1 允许空值
            this._isHide = dr["IsHide"] == DBNull.Value ? false : (System.Boolean)dr["IsHide"]; //是否隐藏[GetList] 数据类型bit 大小1 允许空值
            this._folderName = dr["FolderName"] == DBNull.Value ? null : (System.String)dr["FolderName"]; // 数据类型nvarchar 大小100 允许空值
            this._isDeleted = dr["IsDeleted"] == DBNull.Value ? false : (System.Boolean)dr["IsDeleted"]; // 数据类型bit 大小1 允许空值
        }
        #endregion

        #region 使用只读只进的数据流的构造函数TagInfo(IDataRecord dr, string[] columnNames)
        /// <summary>
        /// 使用只读只进的数据流的构造函数
        /// </summary>
        /// <param name="dr">只读只进的数据流</param>
        /// <param name="columnNames">需要实例化的字段列表</param>
        public TagInfo(IDataRecord dr, string[] columnNames)
        {
            if (columnNames == null || columnNames.Length <= 0)
                return;
            string rowIndexName = dr.GetName(0);
            if (!string.IsNullOrEmpty(rowIndexName) && rowIndexName.ToLower() == "rowindex")
            {
                this.RowIndex = (long)dr[0];
            }
            foreach (string columnName in columnNames)
            {
                if (!string.IsNullOrEmpty(columnName))
                {
                    switch (columnName.ToLower())
                    {
                        case "tagid":
                            this._tagID = dr["TagID"] == DBNull.Value ? 0 : (System.Int32)dr["TagID"]; // 数据类型int 大小4 不允许空值
                            break;
                        case "tagcategoryid":
                            this._tagCategoryID = dr["TagCategoryID"] == DBNull.Value ? (int)0 : (System.Int32)dr["TagCategoryID"]; //标签分类ID[GetList] 数据类型int 大小4 不允许空值
                            break;
                        case "name":
                            this._name = dr["Name"] == DBNull.Value ? null : (System.String)dr["Name"]; // 数据类型nvarchar 大小50 不允许空值
                            break;
                        case "articlecount":
                            this._articleCount = dr["ArticleCount"] == DBNull.Value ? (int)0 : (System.Int32)dr["ArticleCount"]; //文章数统计[GetList] 数据类型int 大小4 不允许空值
                            break;
                        case "iscommend":
                            this._isCommend = dr["IsCommend"] == DBNull.Value ? false : (System.Boolean)dr["IsCommend"]; //是否推荐[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case "issys":
                            this._isSys = dr["IsSys"] == DBNull.Value ? false : (System.Boolean)dr["IsSys"]; //是否系统定义标签[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case "ishide":
                            this._isHide = dr["IsHide"] == DBNull.Value ? false : (System.Boolean)dr["IsHide"]; //是否隐藏[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case "foldername":
                            this._folderName = dr["FolderName"] == DBNull.Value ? null : (System.String)dr["FolderName"]; // 数据类型nvarchar 大小100 允许空值
                            break;
                        case "isdeleted":
                            this._isDeleted = dr["IsDeleted"] == DBNull.Value ? false : (System.Boolean)dr["IsDeleted"]; // 数据类型bit 大小1 允许空值
                            break;
                        default:
                            break;
                    }
                }
            }
        }
        #endregion

        #region 使用只读只进的数据流的构造函数TagInfo(IDataRecord dr, TagInfoEnumeration[] columnNames)
        /// <summary>
        /// 使用只读只进的数据流的构造函数
        /// </summary>
        /// <param name="dr">只读只进的数据流</param>
        /// <param name="columnNames">需要实例化的字段列表</param>
        public TagInfo(IDataRecord dr, TagInfoEnumeration[] columnNames)
        {
            if (columnNames == null || columnNames.Length <= 0)
                return;
            string rowIndexName = dr.GetName(0);
            if (!string.IsNullOrEmpty(rowIndexName) && rowIndexName.ToLower() == "rowindex")
            {
                this.RowIndex = (long)dr[0];
            }
            foreach (TagInfoEnumeration columnName in columnNames)
            {
                    switch (columnName)
                    {
                        case TagInfoEnumeration.TagID:
                            this._tagID = dr["TagID"] == DBNull.Value ? 0 : (System.Int32)dr["TagID"]; // 数据类型int 大小4 不允许空值
                            break;
                        case TagInfoEnumeration.TagCategoryID:
                            this._tagCategoryID = dr["TagCategoryID"] == DBNull.Value ? (int)0 : (System.Int32)dr["TagCategoryID"]; //标签分类ID[GetList] 数据类型int 大小4 不允许空值
                            break;
                        case TagInfoEnumeration.Name:
                            this._name = dr["Name"] == DBNull.Value ? null : (System.String)dr["Name"]; // 数据类型nvarchar 大小50 不允许空值
                            break;
                        case TagInfoEnumeration.ArticleCount:
                            this._articleCount = dr["ArticleCount"] == DBNull.Value ? (int)0 : (System.Int32)dr["ArticleCount"]; //文章数统计[GetList] 数据类型int 大小4 不允许空值
                            break;
                        case TagInfoEnumeration.IsCommend:
                            this._isCommend = dr["IsCommend"] == DBNull.Value ? false : (System.Boolean)dr["IsCommend"]; //是否推荐[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case TagInfoEnumeration.IsSys:
                            this._isSys = dr["IsSys"] == DBNull.Value ? false : (System.Boolean)dr["IsSys"]; //是否系统定义标签[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case TagInfoEnumeration.IsHide:
                            this._isHide = dr["IsHide"] == DBNull.Value ? false : (System.Boolean)dr["IsHide"]; //是否隐藏[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case TagInfoEnumeration.FolderName:
                            this._folderName = dr["FolderName"] == DBNull.Value ? null : (System.String)dr["FolderName"]; // 数据类型nvarchar 大小100 允许空值
                            break;
                        case TagInfoEnumeration.IsDeleted:
                            this._isDeleted = dr["IsDeleted"] == DBNull.Value ? false : (System.Boolean)dr["IsDeleted"]; // 数据类型bit 大小1 允许空值
                            break;
                        default:
                            break;
                    }
            }
        }
        #endregion

        #region  使用DataRow构造函数 TagInfo(DataRow dr)
        /// <summary>
        /// 使用DataRow构造函数
        /// </summary>
        /// <param name="dr">DataRow</param>
        public TagInfo(DataRow dr)
        {
            this._tagID = dr["TagID"] == DBNull.Value ? 0 : (System.Int32)dr["TagID"]; // 数据类型int 大小4 不允许空值
            this._tagCategoryID = dr["TagCategoryID"] == DBNull.Value ? (int)0 : (System.Int32)dr["TagCategoryID"]; //标签分类ID[GetList] 数据类型int 大小4 不允许空值
            this._name = dr["Name"] == DBNull.Value ? null : (System.String)dr["Name"]; // 数据类型nvarchar 大小50 不允许空值
            this._articleCount = dr["ArticleCount"] == DBNull.Value ? (int)0 : (System.Int32)dr["ArticleCount"]; //文章数统计[GetList] 数据类型int 大小4 不允许空值
            this._isCommend = dr["IsCommend"] == DBNull.Value ? false : (System.Boolean)dr["IsCommend"]; //是否推荐[GetList] 数据类型bit 大小1 允许空值
            this._isSys = dr["IsSys"] == DBNull.Value ? false : (System.Boolean)dr["IsSys"]; //是否系统定义标签[GetList] 数据类型bit 大小1 允许空值
            this._isHide = dr["IsHide"] == DBNull.Value ? false : (System.Boolean)dr["IsHide"]; //是否隐藏[GetList] 数据类型bit 大小1 允许空值
            this._folderName = dr["FolderName"] == DBNull.Value ? null : (System.String)dr["FolderName"]; // 数据类型nvarchar 大小100 允许空值
            this._isDeleted = dr["IsDeleted"] == DBNull.Value ? false : (System.Boolean)dr["IsDeleted"]; // 数据类型bit 大小1 允许空值
        }
        #endregion

        #region 使用DataRow构造函数 TagInfo(DataRow dr, string[] columnNames)
        /// <summary>
        /// 使用DataRow构造函数
        /// </summary>
        /// <param name="dr">DataRow</param>
        /// <param name="columnNames">需要实例化的字段列表</param>
        public TagInfo(DataRow dr, string[] columnNames)
        {
            if (columnNames == null || columnNames.Length <= 0)
                return;
            foreach (string columnName in columnNames)
            {
                if (!string.IsNullOrEmpty(columnName))
                {
                    switch (columnName.ToLower())
                    {
                        case "tagid":
                            this._tagID = dr["TagID"] == DBNull.Value ? 0 : (System.Int32)dr["TagID"]; // 数据类型int 大小4 不允许空值
                            break;
                        case "tagcategoryid":
                            this._tagCategoryID = dr["TagCategoryID"] == DBNull.Value ? (int)0 : (System.Int32)dr["TagCategoryID"]; //标签分类ID[GetList] 数据类型int 大小4 不允许空值
                            break;
                        case "name":
                            this._name = dr["Name"] == DBNull.Value ? null : (System.String)dr["Name"]; // 数据类型nvarchar 大小50 不允许空值
                            break;
                        case "articlecount":
                            this._articleCount = dr["ArticleCount"] == DBNull.Value ? (int)0 : (System.Int32)dr["ArticleCount"]; //文章数统计[GetList] 数据类型int 大小4 不允许空值
                            break;
                        case "iscommend":
                            this._isCommend = dr["IsCommend"] == DBNull.Value ? false : (System.Boolean)dr["IsCommend"]; //是否推荐[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case "issys":
                            this._isSys = dr["IsSys"] == DBNull.Value ? false : (System.Boolean)dr["IsSys"]; //是否系统定义标签[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case "ishide":
                            this._isHide = dr["IsHide"] == DBNull.Value ? false : (System.Boolean)dr["IsHide"]; //是否隐藏[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case "foldername":
                            this._folderName = dr["FolderName"] == DBNull.Value ? null : (System.String)dr["FolderName"]; // 数据类型nvarchar 大小100 允许空值
                            break;
                        case "isdeleted":
                            this._isDeleted = dr["IsDeleted"] == DBNull.Value ? false : (System.Boolean)dr["IsDeleted"]; // 数据类型bit 大小1 允许空值
                            break;
                        default:
                            break;
                    }
                }
            }
        }
        #endregion

        #region 使用DataRow构造函数 TagInfo(DataRow dr, TagInfoEnumeration[] columnNames)
        /// <summary>
        /// 使用DataRow构造函数
        /// </summary>
        /// <param name="dr">DataRow</param>
        /// <param name="columnNames">需要实例化的字段列表</param>
        public TagInfo(DataRow dr, TagInfoEnumeration[] columnNames)
        {
            if (columnNames == null || columnNames.Length <= 0)
                return;
            foreach (TagInfoEnumeration columnName in columnNames)
            {
                    switch (columnName)
                    {
                        case TagInfoEnumeration.TagID:
                            this._tagID = dr["TagID"] == DBNull.Value ? 0 : (System.Int32)dr["TagID"]; // 数据类型int 大小4 不允许空值
                            break;
                        case TagInfoEnumeration.TagCategoryID:
                            this._tagCategoryID = dr["TagCategoryID"] == DBNull.Value ? (int)0 : (System.Int32)dr["TagCategoryID"]; //标签分类ID[GetList] 数据类型int 大小4 不允许空值
                            break;
                        case TagInfoEnumeration.Name:
                            this._name = dr["Name"] == DBNull.Value ? null : (System.String)dr["Name"]; // 数据类型nvarchar 大小50 不允许空值
                            break;
                        case TagInfoEnumeration.ArticleCount:
                            this._articleCount = dr["ArticleCount"] == DBNull.Value ? (int)0 : (System.Int32)dr["ArticleCount"]; //文章数统计[GetList] 数据类型int 大小4 不允许空值
                            break;
                        case TagInfoEnumeration.IsCommend:
                            this._isCommend = dr["IsCommend"] == DBNull.Value ? false : (System.Boolean)dr["IsCommend"]; //是否推荐[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case TagInfoEnumeration.IsSys:
                            this._isSys = dr["IsSys"] == DBNull.Value ? false : (System.Boolean)dr["IsSys"]; //是否系统定义标签[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case TagInfoEnumeration.IsHide:
                            this._isHide = dr["IsHide"] == DBNull.Value ? false : (System.Boolean)dr["IsHide"]; //是否隐藏[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case TagInfoEnumeration.FolderName:
                            this._folderName = dr["FolderName"] == DBNull.Value ? null : (System.String)dr["FolderName"]; // 数据类型nvarchar 大小100 允许空值
                            break;
                        case TagInfoEnumeration.IsDeleted:
                            this._isDeleted = dr["IsDeleted"] == DBNull.Value ? false : (System.Boolean)dr["IsDeleted"]; // 数据类型bit 大小1 允许空值
                            break;
                        default:
                            break;
                    }
            }
        }
        #endregion

        #region  使用DataRowView构造函数 TagInfo(DataRowView dr)
        /// <summary>
        /// 使用DataRowView构造函数
        /// </summary>
        /// <param name="dr">DataRowView</param>
        public TagInfo(DataRowView dr)
        {
            this._tagID = dr["TagID"] == DBNull.Value ? 0 : (System.Int32)dr["TagID"]; // 数据类型int 大小4 不允许空值
            this._tagCategoryID = dr["TagCategoryID"] == DBNull.Value ? (int)0 : (System.Int32)dr["TagCategoryID"]; //标签分类ID[GetList] 数据类型int 大小4 不允许空值
            this._name = dr["Name"] == DBNull.Value ? null : (System.String)dr["Name"]; // 数据类型nvarchar 大小50 不允许空值
            this._articleCount = dr["ArticleCount"] == DBNull.Value ? (int)0 : (System.Int32)dr["ArticleCount"]; //文章数统计[GetList] 数据类型int 大小4 不允许空值
            this._isCommend = dr["IsCommend"] == DBNull.Value ? false : (System.Boolean)dr["IsCommend"]; //是否推荐[GetList] 数据类型bit 大小1 允许空值
            this._isSys = dr["IsSys"] == DBNull.Value ? false : (System.Boolean)dr["IsSys"]; //是否系统定义标签[GetList] 数据类型bit 大小1 允许空值
            this._isHide = dr["IsHide"] == DBNull.Value ? false : (System.Boolean)dr["IsHide"]; //是否隐藏[GetList] 数据类型bit 大小1 允许空值
            this._folderName = dr["FolderName"] == DBNull.Value ? null : (System.String)dr["FolderName"]; // 数据类型nvarchar 大小100 允许空值
            this._isDeleted = dr["IsDeleted"] == DBNull.Value ? false : (System.Boolean)dr["IsDeleted"]; // 数据类型bit 大小1 允许空值
        }
        #endregion

        #region 使用DataRowView构造函数 TagInfo(DataRowView dr, string[] columnNames)
        /// <summary>
        /// 使用DataRowView构造函数
        /// </summary>
        /// <param name="dr">DataRowView</param>
        /// <param name="columnNames">需要实例化的字段列表</param>
        public TagInfo(DataRowView dr, string[] columnNames)
        {
            if (columnNames == null || columnNames.Length <= 0)
                return;
            foreach (string columnName in columnNames)
            {
                if (!string.IsNullOrEmpty(columnName))
                {
                    switch (columnName.ToLower())
                    {
                        case "tagid":
                            this._tagID = dr["TagID"] == DBNull.Value ? 0 : (System.Int32)dr["TagID"]; // 数据类型int 大小4 不允许空值
                            break;
                        case "tagcategoryid":
                            this._tagCategoryID = dr["TagCategoryID"] == DBNull.Value ? (int)0 : (System.Int32)dr["TagCategoryID"]; //标签分类ID[GetList] 数据类型int 大小4 不允许空值
                            break;
                        case "name":
                            this._name = dr["Name"] == DBNull.Value ? null : (System.String)dr["Name"]; // 数据类型nvarchar 大小50 不允许空值
                            break;
                        case "articlecount":
                            this._articleCount = dr["ArticleCount"] == DBNull.Value ? (int)0 : (System.Int32)dr["ArticleCount"]; //文章数统计[GetList] 数据类型int 大小4 不允许空值
                            break;
                        case "iscommend":
                            this._isCommend = dr["IsCommend"] == DBNull.Value ? false : (System.Boolean)dr["IsCommend"]; //是否推荐[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case "issys":
                            this._isSys = dr["IsSys"] == DBNull.Value ? false : (System.Boolean)dr["IsSys"]; //是否系统定义标签[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case "ishide":
                            this._isHide = dr["IsHide"] == DBNull.Value ? false : (System.Boolean)dr["IsHide"]; //是否隐藏[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case "foldername":
                            this._folderName = dr["FolderName"] == DBNull.Value ? null : (System.String)dr["FolderName"]; // 数据类型nvarchar 大小100 允许空值
                            break;
                        case "isdeleted":
                            this._isDeleted = dr["IsDeleted"] == DBNull.Value ? false : (System.Boolean)dr["IsDeleted"]; // 数据类型bit 大小1 允许空值
                            break;
                        default:
                            break;
                    }
                }
            }
        }
        #endregion
        #region 使用DataRowView构造函数 TagInfo(DataRowView dr, TagInfoEnumeration[] columnNames)
        /// <summary>
        /// 使用DataRowView构造函数
        /// </summary>
        /// <param name="dr">DataRowView</param>
        /// <param name="columnNames">需要实例化的字段列表</param>
        public TagInfo(DataRowView dr, TagInfoEnumeration[] columnNames)
        {
            if (columnNames == null || columnNames.Length <= 0)
                return;
            foreach (TagInfoEnumeration columnName in columnNames)
            {
                    switch (columnName)
                    {
                        case TagInfoEnumeration.TagID:
                            this._tagID = dr["TagID"] == DBNull.Value ? 0 : (System.Int32)dr["TagID"]; // 数据类型int 大小4 不允许空值
                            break;
                        case TagInfoEnumeration.TagCategoryID:
                            this._tagCategoryID = dr["TagCategoryID"] == DBNull.Value ? (int)0 : (System.Int32)dr["TagCategoryID"]; //标签分类ID[GetList] 数据类型int 大小4 不允许空值
                            break;
                        case TagInfoEnumeration.Name:
                            this._name = dr["Name"] == DBNull.Value ? null : (System.String)dr["Name"]; // 数据类型nvarchar 大小50 不允许空值
                            break;
                        case TagInfoEnumeration.ArticleCount:
                            this._articleCount = dr["ArticleCount"] == DBNull.Value ? (int)0 : (System.Int32)dr["ArticleCount"]; //文章数统计[GetList] 数据类型int 大小4 不允许空值
                            break;
                        case TagInfoEnumeration.IsCommend:
                            this._isCommend = dr["IsCommend"] == DBNull.Value ? false : (System.Boolean)dr["IsCommend"]; //是否推荐[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case TagInfoEnumeration.IsSys:
                            this._isSys = dr["IsSys"] == DBNull.Value ? false : (System.Boolean)dr["IsSys"]; //是否系统定义标签[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case TagInfoEnumeration.IsHide:
                            this._isHide = dr["IsHide"] == DBNull.Value ? false : (System.Boolean)dr["IsHide"]; //是否隐藏[GetList] 数据类型bit 大小1 允许空值
                            break;
                        case TagInfoEnumeration.FolderName:
                            this._folderName = dr["FolderName"] == DBNull.Value ? null : (System.String)dr["FolderName"]; // 数据类型nvarchar 大小100 允许空值
                            break;
                        case TagInfoEnumeration.IsDeleted:
                            this._isDeleted = dr["IsDeleted"] == DBNull.Value ? false : (System.Boolean)dr["IsDeleted"]; // 数据类型bit 大小1 允许空值
                            break;
                        default:
                            break;
                    }
            }
        }
        #endregion
        #endregion



        #region 数据列属性

        private System.Int32 _tagID;//
        private System.Int32 _tagCategoryID;//标签分类ID[GetList]
        private System.String _name;//
        private System.Int32 _articleCount;//文章数统计[GetList]
        private System.Boolean _isCommend;//是否推荐[GetList]
        private System.Boolean _isSys;//是否系统定义标签[GetList]
        private System.Boolean _isHide;//是否隐藏[GetList]
        private System.String _folderName;//
        private System.Boolean _isDeleted;//


        /// <summary>
        /// 获取或者设置 TagID 属性.
        ///   
        /// </summary>
        /// <value>类型是 int.</value>
        /// <remarks>
        /// 该属性 不能设置为空
        /// </remarks>
        public System.Int32 TagID
        {
            get { return _tagID; }
            set {
                if (_tagID == value)
                {
                    return;
                }               
                _tagID = value; }
        }
        /// <summary>
        /// 获取或者设置 TagCategoryID 属性.
        ///    标签分类ID[GetList]
        /// </summary>
        /// <value>类型是 int.</value>
        /// <remarks>
        /// 该属性 不能设置为空
        /// </remarks>
        public System.Int32 TagCategoryID
        {
            get { return _tagCategoryID; }
            set {
                if (_tagCategoryID == value)
                {
                    return;
                }               
                _tagCategoryID = value; }
        }
        /// <summary>
        /// 获取或者设置 Name 属性.
        ///   
        /// </summary>
        /// <value>类型是 nvarchar.</value>
        /// <remarks>
        /// 该属性 不能设置为空
        /// </remarks>
        public System.String Name
        {
            get { return _name; }
            set {
                if (_name == value)
                {
                    return;
                }               
                _name = value; }
        }
        /// <summary>
        /// 获取或者设置 ArticleCount 属性.
        ///    文章数统计[GetList]
        /// </summary>
        /// <value>类型是 int.</value>
        /// <remarks>
        /// 该属性 不能设置为空
        /// </remarks>
        public System.Int32 ArticleCount
        {
            get { return _articleCount; }
            set {
                if (_articleCount == value)
                {
                    return;
                }               
                _articleCount = value; }
        }
        /// <summary>
        /// 获取或者设置 IsCommend 属性.
        ///    是否推荐[GetList]
        /// </summary>
        /// <value>类型是 bit.</value>
        /// <remarks>
        /// 该属性 能设置为空
        /// 如果该属性设置为Null,那么返回 false
        /// </remarks>
        public System.Boolean IsCommend
        {
            get { return _isCommend; }
            set {
                if (_isCommend == value)
                {
                    return;
                }               
                _isCommend = value; }
        }
        /// <summary>
        /// 获取或者设置 IsSys 属性.
        ///    是否系统定义标签[GetList]
        /// </summary>
        /// <value>类型是 bit.</value>
        /// <remarks>
        /// 该属性 能设置为空
        /// 如果该属性设置为Null,那么返回 false
        /// </remarks>
        public System.Boolean IsSys
        {
            get { return _isSys; }
            set {
                if (_isSys == value)
                {
                    return;
                }               
                _isSys = value; }
        }
        /// <summary>
        /// 获取或者设置 IsHide 属性.
        ///    是否隐藏[GetList]
        /// </summary>
        /// <value>类型是 bit.</value>
        /// <remarks>
        /// 该属性 能设置为空
        /// 如果该属性设置为Null,那么返回 false
        /// </remarks>
        public System.Boolean IsHide
        {
            get { return _isHide; }
            set {
                if (_isHide == value)
                {
                    return;
                }               
                _isHide = value; }
        }
        /// <summary>
        /// 获取或者设置 FolderName 属性.
        ///   
        /// </summary>
        /// <value>类型是 nvarchar.</value>
        /// <remarks>
        /// 该属性 能设置为空
        /// </remarks>
        public System.String FolderName
        {
            get { return _folderName; }
            set {
                if (_folderName == value)
                {
                    return;
                }               
                _folderName = value; }
        }
        /// <summary>
        /// 获取或者设置 IsDeleted 属性.
        ///   
        /// </summary>
        /// <value>类型是 bit.</value>
        /// <remarks>
        /// 该属性 能设置为空
        /// 如果该属性设置为Null,那么返回 false
        /// </remarks>
        public System.Boolean IsDeleted
        {
            get { return _isDeleted; }
            set {
                if (_isDeleted == value)
                {
                    return;
                }               
                _isDeleted = value; }
        }
        #endregion

        #region 序列化和反序列化 静态方法
        /// <summary>
        /// 将对象序列化到文件
        /// </summary>
        /// <param name="path">需要保存的路径</param>
        /// <returns>是否保存成功</returns>
        public bool Serialize(string path)
        {
            return Serialize(path, this);
        }
        /// <summary>
        /// 将对象序列化
        /// </summary>
        /// <param name="path">需要保存的路径</param>
        /// <param name="objTagInfo">TagInfo对象</param>
        /// <returns>是否序列化成功</returns>
        public static bool Serialize(string path, TagInfo objTagInfo)
        {
            try
            {
                string dirName = System.IO.Path.GetDirectoryName(path);
                if (!Directory.Exists(dirName))
                {
                    Directory.CreateDirectory(dirName);
                }
                FileStream fs = new FileStream(path, FileMode.Create);
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(fs, objTagInfo);
                fs.Close();
                fs.Dispose();               
                return true;
            }
            catch
            {
                return false;
            }
        }
        /// <summary>
        /// 将对象反序列化
        /// </summary>
        /// <param name="path">源对象的路径</param>
        /// <returns>返回新的TagInfo对象</returns>
        public static TagInfo DeSerialize(string path)
        {
       
            try
            {
                FileStream fs = new FileStream(path, FileMode.Open);
                BinaryFormatter formatter = new BinaryFormatter();
                TagInfo objTagInfo = (TagInfo)formatter.Deserialize(fs);
                fs.Close();
                fs.Dispose();
                return objTagInfo;
            }
            catch
            {
                return null;
            }
        }
        #endregion
        #region 字符串序列化
        /// <summary>
        /// 将对象转化为以逗号分割的字符串列表,类似序列化
        /// </summary>
        /// <returns>字符串</returns>
        public string ToSplitString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(_tableName);
            sb.Append(",");
            sb.Append(this._tagID);
            sb.Append(",");
            sb.Append(this._tagCategoryID);
            sb.Append(",");
            sb.Append(this._name);
            sb.Append(",");
            sb.Append(this._articleCount);
            sb.Append(",");
            sb.Append(this._isCommend);
            sb.Append(",");
            sb.Append(this._isSys);
            sb.Append(",");
            sb.Append(this._isHide);
            sb.Append(",");
            sb.Append(this._folderName);
            sb.Append(",");
            sb.Append(this._isDeleted);
            return sb.ToString();
        }
        /// <summary>
        /// 从字符串中初始化对象,类似反序列化
        /// </summary>
        /// <param name="objString">对象字符串</param>
        public void FormSplitString(string objString)
        {
            if (objString == null)
            {
                return;
            }
            string[] objs = objString.Split(Convert.ToChar(","));
            if (objs.Length != 10)
            {
                return;
            }
            if (objs[1] != null || objs[1].Length >= 1)
            {
                this._tagID = System.Int32.Parse(objs[1]);
            }
            if (objs[2] != null || objs[2].Length >= 1)
            {
                this._tagCategoryID = System.Int32.Parse(objs[2]);
            }
            if (objs[3] != null || objs[3].Length >= 1)
            {
                this._name = objs[3];
            }
            if (objs[4] != null || objs[4].Length >= 1)
            {
                this._articleCount = System.Int32.Parse(objs[4]);
            }
            if (objs[5] != null || objs[5].Length >= 1)
            {
                this._isCommend = System.Boolean.Parse(objs[5]);
            }
            if (objs[6] != null || objs[6].Length >= 1)
            {
                this._isSys = System.Boolean.Parse(objs[6]);
            }
            if (objs[7] != null || objs[7].Length >= 1)
            {
                this._isHide = System.Boolean.Parse(objs[7]);
            }
            if (objs[8] != null || objs[8].Length >= 1)
            {
                this._folderName = objs[8];
            }
            if (objs[9] != null || objs[9].Length >= 1)
            {
                this._isDeleted = System.Boolean.Parse(objs[9]);
            }
        }
        #endregion

        #region 将对象转化为Url连接字符串  string ToUrlEncodeLinkString()
        /// <summary>
        /// 将对象转化为Url连接字符串
        /// </summary>
        /// <returns>字符串</returns>
        public string ToUrlEncodeLinkString()
        {
            System.Text.StringBuilder sbStr = new System.Text.StringBuilder(1024);
            sbStr.Append("&TagID=").Append(System.Web.HttpUtility.UrlEncode(this._tagID.ToString()));
            sbStr.Append("&TagCategoryID=").Append(System.Web.HttpUtility.UrlEncode(this._tagCategoryID.ToString()));
            if (!string.IsNullOrEmpty(this._name))
            {
                sbStr.Append("&Name=").Append(System.Web.HttpUtility.UrlEncode(this._name));
            }
            sbStr.Append("&ArticleCount=").Append(System.Web.HttpUtility.UrlEncode(this._articleCount.ToString()));
            sbStr.Append("&IsCommend=").Append(System.Web.HttpUtility.UrlEncode(this._isCommend.ToString()));
            sbStr.Append("&IsSys=").Append(System.Web.HttpUtility.UrlEncode(this._isSys.ToString()));
            sbStr.Append("&IsHide=").Append(System.Web.HttpUtility.UrlEncode(this._isHide.ToString()));
            if (!string.IsNullOrEmpty(this._folderName))
            {
                sbStr.Append("&FolderName=").Append(System.Web.HttpUtility.UrlEncode(this._folderName));
            }
            sbStr.Append("&IsDeleted=").Append(System.Web.HttpUtility.UrlEncode(this._isDeleted.ToString()));
            return sbStr.ToString();
        }
        #endregion

        #region 将对象转化为Url Javascript格式的Escape连接字符串  string ToUrlEscapeString()
        /// <summary>
        /// 将对象转化为Url连接字符串
        /// </summary>
        /// <returns>字符串</returns>
        public string ToUrlEscapeString()
        {
            System.Text.StringBuilder sbStr = new System.Text.StringBuilder(1024);
            sbStr.Append("&TagID=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._tagID.ToString()));
            sbStr.Append("&TagCategoryID=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._tagCategoryID.ToString()));
            if (!string.IsNullOrEmpty(this._name))
            {
                sbStr.Append("&Name=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._name));
            }
            sbStr.Append("&ArticleCount=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._articleCount.ToString()));
            sbStr.Append("&IsCommend=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._isCommend.ToString()));
            sbStr.Append("&IsSys=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._isSys.ToString()));
            sbStr.Append("&IsHide=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._isHide.ToString()));
            if (!string.IsNullOrEmpty(this._folderName))
            {
                sbStr.Append("&FolderName=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._folderName));
            }
            sbStr.Append("&IsDeleted=").Append(System.Web.HttpUtility.UrlEncodeUnicode(this._isDeleted.ToString()));
            return sbStr.ToString();
        }
        #endregion


        #region 复制对象,返回一个新对象  virtual TagInfo Copy()
        ///<summary>
        ///  复制对象,返回一个新对象
        ///</summary>
        ///<returns>新的TagInfo对象</returns>
        public virtual TagInfo Copy()
        {
            TagInfo copy = new TagInfo();
            copy.RowIndex = this.RowIndex;          
            copy.TagID = this.TagID;
            copy.TagCategoryID = this.TagCategoryID;
            copy.Name = this.Name;
            copy.ArticleCount = this.ArticleCount;
            copy.IsCommend = this.IsCommend;
            copy.IsSys = this.IsSys;
            copy.IsHide = this.IsHide;
            copy.FolderName = this.FolderName;
            copy.IsDeleted = this.IsDeleted;
            return copy;
        }
        #endregion

        #region 返回两个对象是否相等  virtual bool Equals(TagInfo toObject  static bool Equals(TagInfo Object1, TagInfo Object2)

        /// <summary>
        /// 返回是否与指定对象相等
        /// </summary>
        /// <param name="toObject"></param>
        /// <returns></returns>
        public virtual bool Equals(TagInfo toObject)
        {
            if (toObject == null)
                return false;
            return Equals(this, toObject);
        }

        ///<summary>
        /// 判断两个对象是否相等
        ///</summary>
        ///<param name="Object1">TagInfo实体</param>
        ///<param name="Object2">TagInfo实体 </param>
        ///<returns>返回对象是否相等</returns>
        public static bool Equals(TagInfo Object1, TagInfo Object2)
        {
            if (Object1 == null && Object2 == null)
                return true;
            if (Object1 == null ^ Object2 == null)
                return false;
            bool equal = true;
            if (Object1.TagID != Object2.TagID)
                return false;
            if (Object1.TagCategoryID != Object2.TagCategoryID)
                return false;
            if (Object1.Name != null && Object2.Name != null)
            {
                if (Object1.Name != Object2.Name)
                    return false;
            }
            else if (Object1.Name == null ^ Object2.Name == null)
            {
                return false;
            }
            if (Object1.ArticleCount != Object2.ArticleCount)
                return false;
            if (Object1.IsCommend != Object2.IsCommend)
                return false;
            if (Object1.IsSys != Object2.IsSys)
                return false;
            if (Object1.IsHide != Object2.IsHide)
                return false;
            if (Object1.FolderName != null && Object2.FolderName != null)
            {
                if (Object1.FolderName != Object2.FolderName)
                    return false;
            }
            else if (Object1.FolderName == null ^ Object2.FolderName == null)
            {
                return false;
            }
            if (Object1.IsDeleted != Object2.IsDeleted)
                return false;
            return equal;
        }
        #endregion

        #region 返回实体数据表字段的xml Map ToDataEntitiesMap()
        /// <summary>
        /// 返回实体数据表字段的xml Map
        /// </summary>
        /// <returns></returns>
        public static string ToDataEntitiesMap()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
            sb.Append("<EntityMap Version=\"1.0\" xmlns=\"http://www.CrazyCoder.cn/entitymap\" xmlns:xsi=\"http://www.w3.org/2001/xmlSchema-instance\">\n");
            sb.Append("    <Entity Name=\"Qst_Tag\" Namespace=\"CrazyCoder.Entities\" DbName=\"Qst_Tag\" DataBaseName=\"CrazyCoderCn\" NetEntityName=\"TagInfo\">\n");
            sb.Append("        <Property Name=\"TagID\" Type=\"Int32\" DbName=\"TagID\" DbType=\"int\" NullValue=\"\" AllowNull=\"False\" Size=\"4\" Precision=\"10\" NetPropertyName=\"TagID\" IsIdentity=\"True\" />\n");
            sb.Append("        <Property Name=\"TagCategoryID\" Type=\"Int32\" DbName=\"TagCategoryID\" DbType=\"int\" NullValue=\"\" AllowNull=\"False\" Size=\"4\" Precision=\"10\" NetPropertyName=\"TagCategoryID\" IsIdentity=\"False\" />\n");
            sb.Append("        <Property Name=\"Name\" Type=\"String\" DbName=\"Name\" DbType=\"nvarchar\" NullValue=\"\" AllowNull=\"False\" Size=\"50\" Precision=\"0\" NetPropertyName=\"Name\" IsIdentity=\"False\" />\n");
            sb.Append("        <Property Name=\"ArticleCount\" Type=\"Int32\" DbName=\"ArticleCount\" DbType=\"int\" NullValue=\"\" AllowNull=\"False\" Size=\"4\" Precision=\"10\" NetPropertyName=\"ArticleCount\" IsIdentity=\"False\" />\n");
            sb.Append("        <Property Name=\"IsCommend\" Type=\"Boolean\" DbName=\"IsCommend\" DbType=\"bit\" NullValue=\"\" AllowNull=\"True\" Size=\"1\" Precision=\"1\" NetPropertyName=\"IsCommend\" IsIdentity=\"False\" />\n");
            sb.Append("        <Property Name=\"IsSys\" Type=\"Boolean\" DbName=\"IsSys\" DbType=\"bit\" NullValue=\"\" AllowNull=\"True\" Size=\"1\" Precision=\"1\" NetPropertyName=\"IsSys\" IsIdentity=\"False\" />\n");
            sb.Append("        <Property Name=\"IsHide\" Type=\"Boolean\" DbName=\"IsHide\" DbType=\"bit\" NullValue=\"\" AllowNull=\"True\" Size=\"1\" Precision=\"1\" NetPropertyName=\"IsHide\" IsIdentity=\"False\" />\n");
            sb.Append("        <Property Name=\"FolderName\" Type=\"String\" DbName=\"FolderName\" DbType=\"nvarchar\" NullValue=\"\" AllowNull=\"True\" Size=\"100\" Precision=\"0\" NetPropertyName=\"FolderName\" IsIdentity=\"False\" />\n");
            sb.Append("        <Property Name=\"IsDeleted\" Type=\"Boolean\" DbName=\"IsDeleted\" DbType=\"bit\" NullValue=\"\" AllowNull=\"True\" Size=\"1\" Precision=\"1\" NetPropertyName=\"IsDeleted\" IsIdentity=\"False\" />\n");
            sb.Append("    </Entity>\n");
            sb.Append("</EntityMap>\n");
            return sb.ToString();
        }
        #endregion
        #region Toxml 返回存储在实体类中的xml表现形式
        /// <summary>
        /// 返回存储在实体类中的xml表现形式
        /// </summary>
        /// <returns></returns>
        public string Toxml()
        {
            System.xml.Serialization.xmlSerializer xs = new System.xml.Serialization.xmlSerializer(typeof(TagInfo), "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 Fromxmlxml字符串中反序列化获得实体类 
        /// <summary>
        /// 从xml字符串中反序列化获得实体类
        /// </summary>
        /// <param name="xml">xml</param>
        /// <returns></returns>
        public static TagInfo Fromxml(string xml)
        {
            return Fromxml(xml, System.Text.Encoding.UTF8);
        }      
        /// <summary>
        /// 从xml字符串中反序列化获得实体类
        /// </summary>
        /// <param name="xml">xml</param>
        /// <returns></returns>
        public static TagInfo 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(TagInfo));
            TagInfo obj = (TagInfo)ser.Deserialize(tr);
            tr.Close();
            sm.Close();
            return obj;
        }
        #endregion

        #region 获取哈希值 override int GetHashCode()
        /// <summary>
        /// 获取哈希值
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            return this.TagID.GetHashCode() ^
                    this.TagCategoryID.GetHashCode() ^
                    ((this.Name == null) ? string.Empty : this.Name).GetHashCode() ^
                    this.ArticleCount.GetHashCode() ^
                    this.IsCommend.GetHashCode() ^
                    this.IsSys.GetHashCode() ^
                    this.IsHide.GetHashCode() ^
                    ((this.FolderName == null) ? string.Empty : this.FolderName).GetHashCode() ^
                    this.IsDeleted.GetHashCode();
        }
        #endregion

        #region 输出表定义的sql语句  static string ToTableSql()
        /// <summary>
        /// 输出表定义的sql语句
        /// </summary>
        /// <returns></returns>
        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.Qst_Tag')\n");
            sb.Append("            and   type = 'U')\n");
            sb.Append("   drop table dbo.Qst_Tag\n");
            sb.Append("go\n");
            sb.Append("/*==============================================================*/\n");
            sb.Append("/* Table: Qst_Tag                                       */\n");
            sb.Append("/* 创建人: 标签库                                       */\n");
            sb.Append("/* 创建时间: 星期日, 2008年11月30日                                   */\n");
            sb.Append("/*==============================================================*/\n");
            sb.Append("create table dbo.[Qst_Tag] (\n");
            sb.Append("   [TagID]                int          NOT NULL         identity,\n");
            sb.Append("   [TagCategoryID]                int          NOT NULL         default ((0)) ,\n");
            sb.Append("   [Name]                nvarchar(50)          NOT NULL         ,\n");
            sb.Append("   [ArticleCount]                int          NOT NULL         default ((0)) ,\n");
            sb.Append("   [IsCommend]                bit                   default ((0)) ,\n");
            sb.Append("   [IsSys]                bit                   default ((0)) ,\n");
            sb.Append("   [IsHide]                bit                   default ((0)) ,\n");
            sb.Append("   [FolderName]                nvarchar(100)                   ,\n");
            sb.Append("   [IsDeleted]                bit                   default ((0)) ,\n");
            sb.Append("   constraint PK_QST_TAG primary key (TagID)\n");
            sb.Append(")\n");
            sb.Append("go\n");
            sb.Append("execute sp_addextendedproperty 'MS_Description', \n");
            sb.Append("   '标签库',\n");
            sb.Append("   'user', 'dbo', 'table', 'Qst_Tag'\n");
            sb.Append("go\n");
            sb.Append("execute sp_addextendedproperty 'MS_Description', \n");
            sb.Append("   '标签分类ID[GetList]',\n");
            sb.Append("   'user', 'dbo', 'table', 'Qst_Tag', 'column', 'TagCategoryID'\n");
            sb.Append("go\n");
            sb.Append("execute sp_addextendedproperty 'MS_Description', \n");
            sb.Append("   '文章数统计[GetList]',\n");
            sb.Append("   'user', 'dbo', 'table', 'Qst_Tag', 'column', 'ArticleCount'\n");
            sb.Append("go\n");
            sb.Append("execute sp_addextendedproperty 'MS_Description', \n");
            sb.Append("   '是否推荐[GetList]',\n");
            sb.Append("   'user', 'dbo', 'table', 'Qst_Tag', 'column', 'IsCommend'\n");
            sb.Append("go\n");
            sb.Append("execute sp_addextendedproperty 'MS_Description', \n");
            sb.Append("   '是否系统定义标签[GetList]',\n");
            sb.Append("   'user', 'dbo', 'table', 'Qst_Tag', 'column', 'IsSys'\n");
            sb.Append("go\n");
            sb.Append("execute sp_addextendedproperty 'MS_Description', \n");
            sb.Append("   '是否隐藏[GetList]',\n");
            sb.Append("   'user', 'dbo', 'table', 'Qst_Tag', 'column', 'IsHide'\n");
            sb.Append("go\n");
            return sb.ToString();
        }
        #endregion
    }

    #region 实体接口类

    /// <summary>
    /// 数据表Qst_Tag 的实体类 TagInfo 的接口
    /// </summary>
    public partial interface ITagInfo : IDataEntities
    {
        #region 属性
        /// <summary>
        ///
        /// </summary>
        System.Int32 TagID{ get; set; }

        /// <summary>
        /// 标签分类ID[GetList]
        /// </summary>
        System.Int32 TagCategoryID{ get; set; }

        /// <summary>
        ///
        /// </summary>
        System.String Name{ get; set; }

        /// <summary>
        /// 文章数统计[GetList]
        /// </summary>
        System.Int32 ArticleCount{ get; set; }

        /// <summary>
        /// 是否推荐[GetList]
        /// </summary>
        System.Boolean IsCommend{ get; set; }

        /// <summary>
        /// 是否系统定义标签[GetList]
        /// </summary>
        System.Boolean IsSys{ get; set; }

        /// <summary>
        /// 是否隐藏[GetList]
        /// </summary>
        System.Boolean IsHide{ get; set; }

        /// <summary>
        ///
        /// </summary>
        System.String FolderName{ get; set; }

        /// <summary>
        ///
        /// </summary>
        System.Boolean IsDeleted{ get; set; }

        #endregion

        #region 方法
        ///  复制对象,返回一个新对象
        ///</summary>
        ///<returns>新的TagInfo对象</returns>
        TagInfo Copy();
        /// <summary>
        /// 返回两个对象是否相等
        /// </summary>
        /// <param name="toObject"></param>
        /// <returns></returns>
        bool Equals(TagInfo toObject);
        #endregion
    }

    #endregion


    #region 表 的字段枚举
    /// <summary>
    /// 表Qst_Tag的字段枚举
    /// </summary>
    public enum TagInfoEnumeration
    {
        /// <summary>
        /// 默认属性,表示未知属性 枚举值为0
        /// </summary>
        Undefined = 0,
        /// <summary>
        /// TagID : 1 
        /// </summary>
        [EnumTextValue("TagID")]
        [ColumnEnum("TagID", typeof(System.Int32), System.Data.DbType.Int32, true, true, false, true,4)]
        TagID = 1,
        /// <summary>
        /// TagCategoryID : 2 标签分类ID[GetList]
        /// </summary>
        [EnumTextValue("TagCategoryID")]
        [ColumnEnum("TagCategoryID", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
        TagCategoryID = 2,
        /// <summary>
        /// Name : 3 
        /// </summary>
        [EnumTextValue("Name")]
        [ColumnEnum("Name", typeof(System.String), System.Data.DbType.String, false, false, false, true,50)]
        Name = 3,
        /// <summary>
        /// ArticleCount : 4 文章数统计[GetList]
        /// </summary>
        [EnumTextValue("ArticleCount")]
        [ColumnEnum("ArticleCount", typeof(System.Int32), System.Data.DbType.Int32, false, false, false, false,4)]
        ArticleCount = 4,
        /// <summary>
        /// IsCommend : 5 是否推荐[GetList]
        /// </summary>
        [EnumTextValue("IsCommend")]
        [ColumnEnum("IsCommend", typeof(System.Boolean), System.Data.DbType.Boolean, false, false, true, false,1)]
        IsCommend = 5,
        /// <summary>
        /// IsSys : 6 是否系统定义标签[GetList]
        /// </summary>
        [EnumTextValue("IsSys")]
        [ColumnEnum("IsSys", typeof(System.Boolean), System.Data.DbType.Boolean, false, false, true, false,1)]
        IsSys = 6,
        /// <summary>
        /// IsHide : 7 是否隐藏[GetList]
        /// </summary>
        [EnumTextValue("IsHide")]
        [ColumnEnum("IsHide", typeof(System.Boolean), System.Data.DbType.Boolean, false, false, true, false,1)]
        IsHide = 7,
        /// <summary>
        /// FolderName : 8 
        /// </summary>
        [EnumTextValue("FolderName")]
        [ColumnEnum("FolderName", typeof(System.String), System.Data.DbType.String, false, false, true, false,100)]
        FolderName = 8,
        /// <summary>
        /// IsDeleted : 9 
        /// </summary>
        [EnumTextValue("IsDeleted")]
        [ColumnEnum("IsDeleted", typeof(System.Boolean), System.Data.DbType.Boolean, false, false, true, false,1)]
        IsDeleted = 9
    }
    #endregion


    #region 比较规则
    /// <summary>
    ///  TagInfo的比较规则
    /// </summary>
    public partial class TagInfoCompare
    {
        /// <summary>
        /// 根据  统计
        /// </summary>
        /// <param name="obj1">标签库 对象</param>
        /// <param name="obj2">标签库 对象</param>
        /// <returns>比较结果</returns>
        public static int TagID(TagInfo obj1,TagInfo obj2)
        {
            if (obj1.TagID > obj2.TagID)
            {
                return 1;
            }
            else if (obj1.TagID == obj2.TagID)
            {
                return 0;
            }
            else
            {
                return -1;
            }
        }    
        /// <summary>
        /// 根据 标签分类ID[GetList] 统计
        /// </summary>
        /// <param name="obj1">标签库 对象</param>
        /// <param name="obj2">标签库 对象</param>
        /// <returns>比较结果</returns>
        public static int TagCategoryID(TagInfo obj1,TagInfo obj2)
        {
            if (obj1.TagCategoryID > obj2.TagCategoryID)
            {
                return 1;
            }
            else if (obj1.TagCategoryID == obj2.TagCategoryID)
            {
                return 0;
            }
            else
            {
                return -1;
            }
        }    
        /// <summary>
        /// 根据  统计
        /// </summary>
        /// <param name="obj1">标签库 对象</param>
        /// <param name="obj2">标签库 对象</param>
        /// <returns>比较结果</returns>
        public static int Name(TagInfo obj1,TagInfo obj2)
        {
            return System.Collections.Comparer.Default.Compare(obj1.Name, obj2.Name);
        }    
        /// <summary>
        /// 根据 文章数统计[GetList] 统计
        /// </summary>
        /// <param name="obj1">标签库 对象</param>
        /// <param name="obj2">标签库 对象</param>
        /// <returns>比较结果</returns>
        public static int ArticleCount(TagInfo obj1,TagInfo obj2)
        {
            if (obj1.ArticleCount > obj2.ArticleCount)
            {
                return 1;
            }
            else if (obj1.ArticleCount == obj2.ArticleCount)
            {
                return 0;
            }
            else
            {
                return -1;
            }
        }    
        /// <summary>
        /// 根据 是否推荐[GetList] 统计
        /// </summary>
        /// <param name="obj1">标签库 对象</param>
        /// <param name="obj2">标签库 对象</param>
        /// <returns>比较结果</returns>
        public static int IsCommend(TagInfo obj1,TagInfo obj2)
        {
            if (obj1.IsCommend && obj2.IsCommend)
            {
                return 0;
            }
            else if (obj1.IsCommend && !obj2.IsCommend)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }    
        /// <summary>
        /// 根据 是否系统定义标签[GetList] 统计
        /// </summary>
        /// <param name="obj1">标签库 对象</param>
        /// <param name="obj2">标签库 对象</param>
        /// <returns>比较结果</returns>
        public static int IsSys(TagInfo obj1,TagInfo obj2)
        {
            if (obj1.IsSys && obj2.IsSys)
            {
                return 0;
            }
            else if (obj1.IsSys && !obj2.IsSys)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }    
        /// <summary>
        /// 根据 是否隐藏[GetList] 统计
        /// </summary>
        /// <param name="obj1">标签库 对象</param>
        /// <param name="obj2">标签库 对象</param>
        /// <returns>比较结果</returns>
        public static int IsHide(TagInfo obj1,TagInfo obj2)
        {
            if (obj1.IsHide && obj2.IsHide)
            {
                return 0;
            }
            else if (obj1.IsHide && !obj2.IsHide)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }    
        /// <summary>
        /// 根据  统计
        /// </summary>
        /// <param name="obj1">标签库 对象</param>
        /// <param name="obj2">标签库 对象</param>
        /// <returns>比较结果</returns>
        public static int FolderName(TagInfo obj1,TagInfo obj2)
        {
            return System.Collections.Comparer.Default.Compare(obj1.FolderName, obj2.FolderName);
        }    
        /// <summary>
        /// 根据  统计
        /// </summary>
        /// <param name="obj1">标签库 对象</param>
        /// <param name="obj2">标签库 对象</param>
        /// <returns>比较结果</returns>
        public static int IsDeleted(TagInfo obj1,TagInfo obj2)
        {
            if (obj1.IsDeleted && obj2.IsDeleted)
            {
                return 0;
            }
            else if (obj1.IsDeleted && !obj2.IsDeleted)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }    
    }
    #endregion



    #region 强类型实体基类 TagInfoCollection
    /// <summary>
    /// TagInfo强类型实体集合
    /// </summary>
    [Serializable]
    public partial class TagInfoCollection : TList<TagInfo>
    {
        #region ExportExcelxml 导出到EXCEL
        /// <summary>
        /// 输入列表为Excel的xml文件
        /// </summary>
        /// <returns>比较结果</returns>
        public string ExportExcelxml()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder(1024);
            #region 头文件
            sb.Append("<?xml version=\"1.0\"?>\n");
            sb.Append("<?mso-application progid=\"Excel.Sheet\"?>\n");
            sb.Append("<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\n");
            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(" <DocumentProperties xmlns=\"urn:schemas-microsoft-com:office:office\">\n");
            sb.Append("  <Author>CrazyCoder 疯狂代码</Author>\n");
            sb.Append("  <LastAuthor>CrazyCoder 疯狂代码</LastAuthor>\n");
            sb.Append("  <Created>2008-11-30 12:17:59</Created>\n");
            sb.Append("  <Company>CrazyCoder.cn</Company>\n");
            sb.Append("  <Version>11.5606</Version>\n");
            sb.Append(" </DocumentProperties>\n");
            sb.Append(" <ExcelWorkbook xmlns=\"urn:schemas-microsoft-com:office:excel\">\n");
            sb.Append("  <WindowHeight>9090</WindowHeight>\n");
            sb.Append("  <WindowWidth>10380</WindowWidth>\n");
            sb.Append("  <WindowTopX>360</WindowTopX>\n");
            sb.Append("  <WindowTopY>45</WindowTopY>\n");
            sb.Append("  <ProtectStructure>False</ProtectStructure>\n");
            sb.Append("  <ProtectWindows>False</ProtectWindows>\n");
            sb.Append(" </ExcelWorkbook>\n");
            sb.Append(" <Styles>\n");
            sb.Append("  <Style ss:ID=\"Default\" ss:Name=\"Normal\">\n");
            sb.Append("   <Alignment ss:Vertical=\"Center\"/>\n");
            sb.Append("   <Borders/>\n");
            sb.Append("   <Font ss:FontName=\"宋体\" x:CharSet=\"134\" ss:Size=\"12\"/>\n");
            sb.Append("   <Interior/>\n");
            sb.Append("   <NumberFormat/>\n");
            sb.Append("   <Protection/>\n");
            sb.Append("  </Style>\n");
            sb.Append(" </Styles>\n");
            sb.Append(" <Worksheet ss:Name=\"Sheet1\">\n");
            sb.Append("  <Table ss:ExpandedColumnCount=\"33\" ss:ExpandedRowCount=\"11\" x:FullColumns=\"1\"\n");
            sb.Append("   x:FullRows=\"1\" ss:DefaultColumnWidth=\"54\" ss:DefaultRowHeight=\"14.25\">\n");
            #endregion
            sb.Append("   <Row>\n");
            #region 标题
            //TagID
            sb.Append("    <Cell><Data ss:Type=\"String\">TagID</Data></Cell>\n");
            //标签分类ID[GetList]
            sb.Append("    <Cell><Data ss:Type=\"String\">标签分类ID[GetList]</Data></Cell>\n");
            //Name
            sb.Append("    <Cell><Data ss:Type=\"String\">Name</Data></Cell>\n");
            //文章数统计[GetList]
            sb.Append("    <Cell><Data ss:Type=\"String\">文章数统计[GetList]</Data></Cell>\n");
            //是否推荐[GetList]
            sb.Append("    <Cell><Data ss:Type=\"String\">是否推荐[GetList]</Data></Cell>\n");
            //是否系统定义标签[GetList]
            sb.Append("    <Cell><Data ss:Type=\"String\">是否系统定义标签[GetList]</Data></Cell>\n");
            //是否隐藏[GetList]
            sb.Append("    <Cell><Data ss:Type=\"String\">是否隐藏[GetList]</Data></Cell>\n");
            //FolderName
            sb.Append("    <Cell><Data ss:Type=\"String\">FolderName</Data></Cell>\n");
            //IsDeleted
            sb.Append("    <Cell><Data ss:Type=\"String\">IsDeleted</Data></Cell>\n");
    #endregion
            sb.Append("   </Row>\n");
            foreach (TagInfo obj in this)
            {
              sb.Append("   <Row>\n");
              #region 内容
                //TagID
                sb.Append("    <Cell><Data ss:Type=\"Number\">");
                sb.Append(obj.TagID);
                sb.Append("</Data></Cell>\n");
                //标签分类ID[GetList]
                sb.Append("    <Cell><Data ss:Type=\"Number\">");
                sb.Append(obj.TagCategoryID);
                sb.Append("</Data></Cell>\n");
                //Name
                sb.Append("    <Cell><Data ss:Type=\"String\">");
                sb.Append(string.IsNullOrEmpty(obj.Name) ? "" : obj.Name.Replace(">", "&gt;").Replace("<", "&lt;"));
                sb.Append("</Data></Cell>\n");
                //文章数统计[GetList]
                sb.Append("    <Cell><Data ss:Type=\"Number\">");
                sb.Append(obj.ArticleCount);
                sb.Append("</Data></Cell>\n");
                //是否推荐[GetList]
                sb.Append("    <Cell><Data ss:Type=\"String\">");
                sb.Append(obj.IsCommend);
                sb.Append("</Data></Cell>\n");
                //是否系统定义标签[GetList]
                sb.Append("    <Cell><Data ss:Type=\"String\">");
                sb.Append(obj.IsSys);
                sb.Append("</Data></Cell>\n");
                //是否隐藏[GetList]
                sb.Append("    <Cell><Data ss:Type=\"String\">");
                sb.Append(obj.IsHide);
                sb.Append("</Data></Cell>\n");
                //FolderName
                sb.Append("    <Cell><Data ss:Type=\"String\">");
                sb.Append(string.IsNullOrEmpty(obj.FolderName) ? "" : obj.FolderName.Replace(">", "&gt;").Replace("<", "&lt;"));
                sb.Append("</Data></Cell>\n");
                //IsDeleted
                sb.Append("    <Cell><Data ss:Type=\"String\">");
                sb.Append(obj.IsDeleted);
                sb.Append("</Data></Cell>\n");
              #endregion
              sb.Append("   </Row>\n");
            }
            sb.Append("  </Table>\n");
            #region 尾文件
            sb.Append("  <WorksheetOptions xmlns=\"urn:schemas-microsoft-com:office:excel\">\n");
            sb.Append("   <Selected/>\n");
            sb.Append("   <Panes>\n");
            sb.Append("    <Pane>\n");
            sb.Append("     <Number>3</Number>\n");
            sb.Append("     <ActiveRow>9</ActiveRow>\n");
            sb.Append("     <ActiveCol>10</ActiveCol>\n");
            sb.Append("    </Pane>\n");
            sb.Append("   </Panes>\n");
            sb.Append("   <ProtectObjects>False</ProtectObjects>\n");
            sb.Append("   <ProtectScenarios>False</ProtectScenarios>\n");
            sb.Append("  </WorksheetOptions>\n");
            sb.Append(" </Worksheet>\n");
            sb.Append("</Workbook>\n");
            #endregion
            return sb.ToString();
        }
        #endregion
        #region Toxml 返回实体类强类型列表的xml表现形式
        /// <summary>
        ///  返回实体类强类型列表的xml表现形式
        /// </summary>
        /// <returns></returns>
        public string Toxml()
        {
            System.xml.Serialization.xmlSerializer xs = new System.xml.Serialization.xmlSerializer(typeof(TagInfoCollection), "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 Fromxmlxml字符串中反序列化获得类 
        /// <summary>
        /// 从xml字符串中反序列化获得类
        /// </summary>
        /// <param name="xml">xml</param>
        /// <returns></returns>
        public static TagInfoCollection Fromxml(string xml)
        {
            return Fromxml(xml, System.Text.Encoding.UTF8);
        }      
        /// <summary>
        /// 从xml字符串中反序列化获得类
        /// </summary>
        /// <param name="xml">xml</param>
        /// <returns></returns>
        public static TagInfoCollection 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(TagInfoCollection));
            TagInfoCollection obj = (TagInfoCollection)ser.Deserialize(tr);
            tr.Close();
            sm.Close();
            return obj;
        }
        #endregion
        #region 创建插入的sql语句 string ToInsertSql()
        /// <summary>
        /// 创建插入的sql语句
        /// </summary>
        /// <returns></returns>
        public string ToInsertSql()
        {
            StringBuilder sb = new StringBuilder();
            foreach (TagInfo obj in this)
            {
                sb.Append("INSERT INTO [Qst_Tag]([TagCategoryID],[Name],[ArticleCount],[IsCommend],[IsSys],[IsHide],[FolderName],[IsDeleted]) \n");
                sb.Append("VALUES (");
                sb.Append(obj.TagCategoryID);
                sb.Append(",");
                sb.Append("'");
                sb.Append(obj.Name);
                sb.Append("'");
                sb.Append(",");
                sb.Append(obj.ArticleCount);
                sb.Append(",");
                sb.Append(obj.IsCommend ? "1":"0");
                sb.Append(",");
                sb.Append(obj.IsSys ? "1":"0");
                sb.Append(",");
                sb.Append(obj.IsHide ? "1":"0");
                sb.Append(",");
                sb.Append("'");
                sb.Append(obj.FolderName);
                sb.Append("'");
                sb.Append(",");
                sb.Append(obj.IsDeleted ? "1":"0");
                sb.Append(")\n");
                sb.Append("Go\n");
            }
            return sb.ToString();
        }
        #endregion
        #region 创建更新的sql语句 string ToUpdateSql()
        /// <summary>
        /// 创建更新的sql语句
        /// </summary>
        /// <returns></returns>
        public string ToUpdateSql()
        {
            StringBuilder sb = new StringBuilder();
            foreach (TagInfo obj in this)
            {
                sb.Append("UPDATE [Qst_Tag] Set\n");
                sb.Append("TagCategoryID =");
                sb.Append(obj.TagCategoryID);
                sb.Append(",");          
                sb.Append("[Name]='");
                sb.Append(obj.Name);
                sb.Append("'");
                sb.Append(",");          
                sb.Append("ArticleCount =");
                sb.Append(obj.ArticleCount);
                sb.Append(",");          
                sb.Append("IsCommend =");
                sb.Append(obj.IsCommend ? "1":"0");
                sb.Append(",");          
                sb.Append("IsSys =");
                sb.Append(obj.IsSys ? "1":"0");
                sb.Append(",");          
                sb.Append("IsHide =");
                sb.Append(obj.IsHide ? "1":"0");
                sb.Append(",");          
                sb.Append("[FolderName]='");
                sb.Append(obj.FolderName);
                sb.Append("'");
                sb.Append(",");          
                sb.Append("IsDeleted =");
                sb.Append(obj.IsDeleted ? "1":"0");
                sb.Append(obj.TagID);
                sb.Append("Go\n");
            }
            return sb.ToString();
        }
        #endregion
        #region 序列化和反序列化 静态方法
        /// <summary>
        /// 将对象序列化
        /// </summary>
        /// <param name="path">需要保存的路径</param>
        /// <param name="objTagInfoCollection">TagInfoCollection对象</param>
        /// <returns>是否序列化成功</returns>
        public static bool Serialize(string path, TagInfoCollection objTagInfoCollection)
        {
            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, objTagInfoCollection);
                fs.Close();
                fs.Dispose();               
                return true;
            }
            catch
            {
                return false;
            }
        }
        /// <summary>
        /// 将对象反序列化
        /// </summary>
        /// <param name="path">源对象的路径</param>
        /// <returns>返回新的TagInfoCollection对象</returns>
        public new static TagInfoCollection DeSerialize(string path)
        {
       
            try
            {
                FileStream fs = new FileStream(path, FileMode.Open);
                BinaryFormatter formatter = new BinaryFormatter();
                TagInfoCollection objTagInfoCollection = (TagInfoCollection)formatter.Deserialize(fs);
                fs.Close();
                fs.Dispose();
                return objTagInfoCollection;
            }
            catch
            {
                return null;
            }
        }
        #endregion
        #region 分页 Paging
        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页面大小</param>
        /// <returns></returns>
        public TagInfoCollection Paging(int pageIndex, int pageSize)
        {
            if (pageIndex <= 0)
            {
                pageIndex = 1;
            }
            if (pageSize <= 0)
            {
                pageSize = 10;
            }
            TagInfoCollection list = new TagInfoCollection();
            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 获取对象
        /// <summary>
        /// 根据主键TagID获取TagInfo标签库对象
        /// </summary>
        /// <param name="tagID">主键tagID</param>
        /// <returns>返回TagInfo标签库</returns>
        public TagInfo GetByTagID(System.Int32 tagID)
        {
            foreach (TagInfo objTagInfo in this)
            {
                if (objTagInfo.TagID == tagID)
                {
                    return objTagInfo;                   
                }
            }
            return null;
        }
        /// <summary>
        /// 根据唯一索引Name获取TagInfo标签库对象
        /// </summary>
        /// <param name="name">唯一索引name</param>
        /// <returns>返回TagInfo标签库</returns>
        public TagInfo GetByName(System.String name)
        {
            foreach (TagInfo objTagInfo in this)
            {
                if (objTagInfo.Name.Equals(name,StringComparison.CurrentCultureIgnoreCase))
                {
                    return objTagInfo;                   
                }
            }
            return null;
        }
        #endregion
        #region 根据对象枚举获取列表
        /// <summary>
        /// 根据对象枚举TagInfoEnumeration获取列表
        /// </summary>
        /// <param name="obj">对象数据</param>
        /// <param name="en">对象列枚举</param>
        /// <returns>TagInfo对象强类型实体列表TagInfoCollection</returns>
        public TagInfoCollection GetList(object obj, TagInfoEnumeration en)
        {
            TagInfoCollection list = new TagInfoCollection();
            foreach (TagInfo objTagInfo in this)
            {
                switch (en)
                {
                    case TagInfoEnumeration.TagID:
                        //根据TagID:取出列表
                        if (obj == null)
                        {
                            break;
                        }
                        else
                        {
                            if (objTagInfo.TagID == (System.Int32)obj)
                            {
                                list.Add(objTagInfo);
                            }
                        }
                        break;
                    case TagInfoEnumeration.TagCategoryID:
                        //根据TagCategoryID:标签分类ID[GetList]取出列表
                        if (obj == null)
                        {
                            break;
                        }
                        else
                        {
                            if (objTagInfo.TagCategoryID == (System.Int32)obj)
                            {
                                list.Add(objTagInfo);
                            }
                        }
                        break;
                    case TagInfoEnumeration.Name:
                        //根据Name:取出列表
                        if (obj == null)
                        {
                            break;
                        }
                        else
                        {
                            if (objTagInfo.Name.Equals((System.String)obj, StringComparison.CurrentCultureIgnoreCase))
                            {
                                list.Add(objTagInfo);
                            }
                        }
                        break;
                    case TagInfoEnumeration.ArticleCount:
                        //根据ArticleCount:文章数统计[GetList]取出列表
                        if (obj == null)
                        {
                            break;
                        }
                        else
                        {
                            if (objTagInfo.ArticleCount == (System.Int32)obj)
                            {
                                list.Add(objTagInfo);
                            }
                        }
                        break;
                    case TagInfoEnumeration.IsCommend:
                        //根据IsCommend:是否推荐[GetList]取出列表
                        if (obj == null)
                        {
                            break;
                        }
                        else
                        {
                            if (objTagInfo.IsCommend == (System.Boolean)obj)
                            {
                                list.Add(objTagInfo);
                            }
                        }
                        break;
                    case TagInfoEnumeration.IsSys:
                        //根据IsSys:是否系统定义标签[GetList]取出列表
                        if (obj == null)
                        {
                            break;
                        }
                        else
                        {
                            if (objTagInfo.IsSys == (System.Boolean)obj)
                            {
                                list.Add(objTagInfo);
                            }
                        }
                        break;
                    case TagInfoEnumeration.IsHide:
                        //根据IsHide:是否隐藏[GetList]取出列表
                        if (obj == null)
                        {
                            break;
                        }
                        else
                        {
                            if (objTagInfo.IsHide == (System.Boolean)obj)
                            {
                                list.Add(objTagInfo);
                            }
                        }
                        break;
                    case TagInfoEnumeration.FolderName:
                        //根据FolderName:取出列表
                        if (obj == null)
                        {
                            break;
                        }
                        else
                        {
                            if (objTagInfo.FolderName.Equals((System.String)obj, StringComparison.CurrentCultureIgnoreCase))
                            {
                                list.Add(objTagInfo);
                            }
                        }
                        break;
                    case TagInfoEnumeration.IsDeleted:
                        //根据IsDeleted:取出列表
                        if (obj == null)
                        {
                            break;
                        }
                        else
                        {
                            if (objTagInfo.IsDeleted == (System.Boolean)obj)
                            {
                                list.Add(objTagInfo);
                            }
                        }
                        break;
                    default:
                        break;
                }
            }
            return list;
        }
        #endregion
        #region 根据开始和结束位置的索引获取列表
        /// <summary>
        /// 根据开始和结束位置的索引获取列表
        /// </summary>
        /// <param name="startIndex">索引开始位置</param>
        /// <param name="endIndex">索引结束位置</param>
        /// <returns>TagInfoCollection</returns>
        public TagInfoCollection GetList(int startIndex, int endIndex)
        {
            TagInfoCollection list = new TagInfoCollection();
            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 根据数字行列获取列表
        /// <summary>
        /// 根据TagCategoryID标签分类ID[GetList] 获取TagInfoQst_Tag对象列表
        /// </summary>
        /// <param name="tagCategoryID">System.Int32标签分类ID[GetList]</param>
        /// <returns>TagInfoCollection TagInfo标签库集合对象列表</returns>
        public TagInfoCollection GetListByTagCategoryID(System.Int32 tagCategoryID)
        {
            TagInfoCollection list = new TagInfoCollection();
            foreach (TagInfo objTagInfo in this)
            {
                if (objTagInfo.TagCategoryID == tagCategoryID)
                {
                    list.Add(objTagInfo);
                }
            }
            return list;
        }
        /// <summary>
        /// 根据ArticleCount文章数统计[GetList] 获取TagInfoQst_Tag对象列表
        /// </summary>
        /// <param name="articleCount">System.Int32文章数统计[GetList]</param>
        /// <returns>TagInfoCollection TagInfo标签库集合对象列表</returns>
        public TagInfoCollection GetListByArticleCount(System.Int32 articleCount)
        {
            TagInfoCollection list = new TagInfoCollection();
            foreach (TagInfo objTagInfo in this)
            {
                if (objTagInfo.ArticleCount == articleCount)
                {
                    list.Add(objTagInfo);
                }
            }
            return list;
        }
        /// <summary>
        /// 根据IsCommend是否推荐[GetList] 获取TagInfoQst_Tag对象列表
        /// </summary>
        /// <param name="isCommend">System.Boolean是否推荐[GetList]</param>
        /// <returns>TagInfoCollection TagInfo标签库集合对象列表</returns>
        public TagInfoCollection GetListByIsCommend(System.Boolean isCommend)
        {
            TagInfoCollection list = new TagInfoCollection();
            foreach (TagInfo objTagInfo in this)
            {
                if (objTagInfo.IsCommend == isCommend)
                {
                    list.Add(objTagInfo);
                }
            }
            return list;
        }
        /// <summary>
        /// 根据IsSys是否系统定义标签[GetList] 获取TagInfoQst_Tag对象列表
        /// </summary>
        /// <param name="isSys">System.Boolean是否系统定义标签[GetList]</param>
        /// <returns>TagInfoCollection TagInfo标签库集合对象列表</returns>
        public TagInfoCollection GetListByIsSys(System.Boolean isSys)
        {
            TagInfoCollection list = new TagInfoCollection();
            foreach (TagInfo objTagInfo in this)
            {
                if (objTagInfo.IsSys == isSys)
                {
                    list.Add(objTagInfo);
                }
            }
            return list;
        }
        /// <summary>
        /// 根据IsHide是否隐藏[GetList] 获取TagInfoQst_Tag对象列表
        /// </summary>
        /// <param name="isHide">System.Boolean是否隐藏[GetList]</param>
        /// <returns>TagInfoCollection TagInfo标签库集合对象列表</returns>
        public TagInfoCollection GetListByIsHide(System.Boolean isHide)
        {
            TagInfoCollection list = new TagInfoCollection();
            foreach (TagInfo objTagInfo in this)
            {
                if (objTagInfo.IsHide == isHide)
                {
                    list.Add(objTagInfo);
                }
            }
            return list;
        }
        /// <summary>
        /// 根据IsDeleted 获取TagInfoQst_Tag对象列表
        /// </summary>
        /// <param name="isDeleted">System.Boolean</param>
        /// <returns>TagInfoCollection TagInfo标签库集合对象列表</returns>
        public TagInfoCollection GetListByIsDeleted(System.Boolean isDeleted)
        {
            TagInfoCollection list = new TagInfoCollection();
            foreach (TagInfo objTagInfo in this)
            {
                if (objTagInfo.IsDeleted == isDeleted)
                {
                    list.Add(objTagInfo);
                }
            }
            return list;
        }
        #endregion
    }
    #endregion

}
 

 

Tags:  代码生成器 疯狂代码生成器

延伸阅读

最新评论

发表评论