⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 category.cs

📁 Maolz个人展示网站源码,全部的代码,.net
💻 CS
字号:
using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace SubSonic.Generated
{

	/// <summary>
	/// This is an ActiveRecord class which wraps the Categories table.
	/// </summary>
	public partial class Category : ActiveRecord<Category>, IActiveRecord
	{
        /// <summary>
        /// 输入分类名称集,以逗号、顿号等分隔,输出分类的Id集合,以逗号分隔开。
        /// </summary>
        /// <param name="parentCategoryNames"></param>
        /// <returns></returns>
        public void SetCategoryParentIds(string parentCategoryNames)
        {
            string[] categoryNames = parentCategoryNames.Trim().Split(MySite.Utils.Constant.tagSeparator, StringSplitOptions.RemoveEmptyEntries);
            if (categoryNames.Length == 0)
                return;
            IList<string> list = new List<string>();
            foreach (string categoryName in categoryNames)
            {
                Category temp = new Category(Category.Columns.Name, categoryName);
                if (temp.IsLoaded && list.Contains(temp.PKId.ToString()) == false)
                    list.Add(temp.PKId.ToString());
            }
            string[] categoryIds = new string[list.Count];
            list.CopyTo(categoryIds, 0);
            
            this.ParentIds=String.Join(",", categoryIds);
        }
        /// <summary>
        /// 输出指定分类的父类集,以逗号分隔
        /// </summary>
        /// <returns></returns>
        public string GetParentCategoryNames() 
        {
            if (string.IsNullOrEmpty(this.ParentIds))
                return string.Empty;
            if (this.ParentIds.Trim().Equals(string.Empty))
                return string.Empty;
            string[] categoryIds=this.ParentIds.Split(new char[] { ',' });
            IList<string> list = new List<string>();
            foreach (string categoryId in categoryIds) 
            {
                Category cate = new Category(categoryId);
                list.Add(cate.Name);
            }
            string[] categoryNames = new string[list.Count];
            list.CopyTo(categoryNames, 0);
            return string.Join(",", categoryNames);
        }
        public static int[] GetCategoryParentIds(string parentCategoryNames) 
        {
            string[] categoryNames = parentCategoryNames.Trim().Split(MySite.Utils.Constant.tagSeparator, StringSplitOptions.RemoveEmptyEntries);
            IList<int> list = new List<int>();
            foreach (string categoryName in categoryNames)
            {
                Category temp = new Category(Category.Columns.Name, categoryName);
                if (temp.IsLoaded==true && list.Contains(temp.PKId) == false)
                    list.Add(temp.PKId);
            }
            int[] categoryIds = new int[list.Count];
            list.CopyTo(categoryIds, 0);
            return categoryIds;
        }
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -