Reputation: 65266
I have dynamic tables in my database and I am having trouble expressing dynamic tables as a custom class. Please take a look at this class that i have created:
public class Table
{
public int Id { get; set; }
public string Name { get; set; }
public int? ParentId { get; set; }
public string Description { get; set; }
public List<Row> Row { get; set; }
}
public class Row
{
private List<Column> RowColumn { get; set; }
}
public class Column
{
public string ColumnName { get; set; }
public string ColumnType { get; set; }
public object ColumnValue { get; set; }
}
Does anyone see a better way to do this? This question is related to https://stackoverflow.com/questions/12230400/which-dbms-allows-very-large-numbers-of-tables-and-columns-per-table
Upvotes: 1
Views: 1410
Reputation: 9837
If you absolutely need a container for dynamic table data, I'd stick with the DataTable
class rather than write my own.
A problem I can see with your design is that you are redundantly saving the column names and types in each cell. Depending on how big these tables are, that could be a lot of wasted memory.
It's best not to reinvent the wheel (unless it has never-before-seen features, like hover ability or something).
Upvotes: 2