problem implementing IHierarchyData

J

Jeff

hi

asp.net 2.0

I have a class named Category in which I want to implement the
iHierarchyData interface:

**********************************
This is the original Category class:
public class Category
{
private int _id;
public int Id { get { return _id; } }

private string _name;
public string Name { get { return _name; } }

private int _parentid;
public int parent { get { return _parent; } }

public Category(int id, string name, int parent)
{
this.Id = id;
this.Name = name;
this.Parent = parent;
}

public static List<Category> GetCategories() {}

**************************************
the original class has a GetCategories method, my problem is that I don't
know where that method should fit in after the iHierarchyData interface is
implemented together with this class:
public class CategoryCollection : List<Category>, IHierarchicalEnumerable

I've studied this example without fully undestanding what I need to do:
http://www.codeproject.com/KB/custo...ise=3&sort=Position&view=Quick&select=2520602
that's why I post my question here in the hope of someone could guide me on
this problem

Jeff
 
S

sloan

Did you work through the Folder/File example at msdn?


The best thing is to work through the example, but HAND CREATE all of their
code line by line.

Its not trivai to work through.
 
J

Jeff

I've seen that example, but I don't fully understand it.

Take this code for example, taken from the example I posted a link to
previous post:
public IHierarchyData GetParent() {
foreach (Category category in Common.GetCategoryData()) {
if (category.CategoryId == this.ParentId)
return category;
}
return null;
}

When I implement IHierarchyData interface into my Category class, then I see
it as bad to all the time call BLL method to get the collection of
categories, in the code above GetCategoryData is called for each iteration
in the loop... I want to implement it so that I can choose between
retrieving the full tree (all categories), or just a branch.. So I need
somehow to send in that parameter....

any suggestions
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top