コード例 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public IndustryDefaultModuleInfo DataRowToModel(DataRow row)
        {
            var model = new IndustryDefaultModuleInfo();

            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["role_id"] != null && row["role_id"].ToString() != "")
                {
                    model.role_id = int.Parse(row["role_id"].ToString());
                }
                if (row["typeName"] != null)
                {
                    model.typeName = row["typeName"].ToString();
                }
                if (row["mName"] != null)
                {
                    model.mName = row["mName"].ToString();
                }
                if (row["isArticle"] != null && row["isArticle"].ToString() != "")
                {
                    if ((row["isArticle"].ToString() == "1") || (row["isArticle"].ToString().ToLower() == "true"))
                    {
                        model.isArticle = true;
                    }
                    else
                    {
                        model.isArticle = false;
                    }
                }
                if (row["url"] != null)
                {
                    model.url = row["url"].ToString();
                }
                if (row["sort_id"] != null && row["sort_id"].ToString() != "")
                {
                    model.sort_id = int.Parse(row["sort_id"].ToString());
                }
                if (row["createDate"] != null && row["createDate"].ToString() != "")
                {
                    model.createDate = DateTime.Parse(row["createDate"].ToString());
                }
                if (row["remark"] != null)
                {
                    model.remark = row["remark"].ToString();
                }
            }
            return(model);
        }
コード例 #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <IndustryDefaultModuleInfo> DataTableToList(DataTable dt)
        {
            var modelList = new List <IndustryDefaultModuleInfo>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                var model = new IndustryDefaultModuleInfo();
                for (int n = 0; n < rowsCount; n++)
                {
                    model = this._repository.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return(modelList);
        }