温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Maolz个人展示网站源码
当前文件:
maolz/SubSonicDAL/MySiteProvider/Custom/Category.cs[3K,2009-6-12 11:47:17],打开代码结构图
maolz/SubSonicDAL/MySiteProvider/Custom/Category.cs[3K,2009-6-12 11:47:17],打开代码结构图1using System; 2
using System.Text; 3
using System.Data; 4
using System.Data.SqlClient; 5
using System.Data.Common; 6
using System.Collections; 7
using System.Collections.Generic; 8
using System.ComponentModel; 9
using System.Configuration; 10
using System.Xml; 11
using System.Xml.Serialization; 12
using SubSonic; 13
using SubSonic.Utilities; 14
15
namespace SubSonic.Generated 16
{ 17
18
/// <summary> 19
/// This is an ActiveRecord class which wraps the Categories table. 20
/// </summary> 21
public partial class Category : ActiveRecord<Category>, IActiveRecord 22
{ 23
/// <summary> 24
/// 输入分类名称集,以逗号、顿号等分隔,输出分类的Id集合,以逗号分隔开。 25
/// </summary> 26
/// <param name="parentCategoryNames"></param> 27
/// <returns></returns> 28
public void SetCategoryParentIds(string parentCategoryNames) 29
{ 30
string[] categoryNames = parentCategoryNames.Trim().Split(MySite.Utils.Constant.tagSeparator, StringSplitOptions.RemoveEmptyEntries); 31
if (categoryNames.Length == 0) 32
return; 33
IList<string> list = new List<string>(); 34
foreach (string categoryName in categoryNames) 35
{ 36
Category temp = new Category(Category.Columns.Name, categoryName); 37
if (temp.IsLoaded && list.Contains(temp.PKId.ToString()) == false) 38
list.Add(temp.PKId.ToString()); 39
} 40
string[] categoryIds = new string[list.Count]; 41
list.CopyTo(categoryIds, 0); 42
43
this.ParentIds=String.Join(",", categoryIds); 44
} 45
/// <summary> 46
/// 输出指定分类的父类集,以逗号分隔 47
/// </summary> 48
/// <returns></returns> 49
public string GetParentCategoryNames() 50
{ 51
if (string.IsNullOrEmpty(this.ParentIds)) 52
return string.Empty; 53
if (this.ParentIds.Trim().Equals(string.Empty)) 54
return string.Empty; 55
string[] categoryIds=this.ParentIds.Split(new char[] { ',' }); 56
IList<string> list = new List<string>(); 57
foreach (string categoryId in categoryIds) 58
{ 59
Category cate = new Category(categoryId); 60
list.Add(cate.Name); 61
} 62
string[] categoryNames = new string[list.Count]; 63
list.CopyTo(categoryNames, 0); 64
return string.Join(",", categoryNames); 65
} 66
public static int[] GetCategoryParentIds(string parentCategoryNames) 67
{ 68
string[] categoryNames = parentCategoryNames.Trim().Split(MySite.Utils.Constant.tagSeparator, StringSplitOptions.RemoveEmptyEntries); 69
IList<int> list = new List<int>(); 70
foreach (string categoryName in categoryNames) 71
{ 72
Category temp = new Category(Category.Columns.Name, categoryName); 73
if (temp.IsLoaded==true && list.Contains(temp.PKId) == false) 74
list.Add(temp.PKId); 75
} 76
int[] categoryIds = new int[list.Count]; 77
list.CopyTo(categoryIds, 0); 78
return categoryIds; 79
} 80
} 81
82
} 83
84






}