0

I was wondering if it is possible to group properties of a c# class. Something like the following:

public class Computer
{
    //First Group
    public string Name{get;set;}
    public string IPAddress{get;set;}

    //Second Group
    public string Driver1Name {get;set;}
    public string Driver1Port{get;set;}

}

The model I have returns 70 columns or so (i.e. the model has ~ 70 properties) and I would like to return all of these to display to the user. Clearly, 70 properties is too much display on one page, and so the contents of this page will be tabbed based on the groupings of these properties (using jquery).

My initial thought was to use attributes, and group by the attributes. But I would like to open this up for other suggestions. Please let me know your thoughts on how I could achieve this.

Cheers!

Anthony Wood
  • 395
  • 1
  • 3
  • 16
  • Not sure to understand: you need to group them in your C# code, or at runtime when accessing properties (using reflection for instance)? – ken2k Aug 09 '12 at 11:35
  • probably at run time (its MVC 3 application) but I guess you could do it using reflection. I am open to any suggestions – Anthony Wood Aug 09 '12 at 11:48

1 Answers1

0

You could use attributes. Either use your own, or the existing attributes that are used by the object browser:

System.ComponentModel.CategoryAttribute.

Ben
  • 34,935
  • 6
  • 74
  • 113