Is it possible (or even a good idea) to expand a table into a collection of collections.
Example scenario:
I want to have a Log class that contains log entries for different machines (with hard coded machine or role names) for different sites.
ie each Site has three machine roles, domain controller, database server and exchange server, and I want my Log class to be contain all of the entries for each machine role at a particular site.
Code:
class Log
{
public int SiteId {get;set;}
public LogEntryCollection DomainControllerLogs {get;set;}
public LogEntryCollection DatabaseServerLogs {get;set;}
public LogEntryCollection ExchangeServerLogs {get;set;}
//...
}
class LogEntryCollection : IList<LogEntry>
{
AddNewEntry(string message, string messageType);
//...
}
class LogEntry
{
private int LogEntryId {get;set;}
public string Message {get;set;}
public string Type {get;set;}
public string MachineRole {get;set;}
public DateTime LogTime {get;set;}
//...
}
I think I could map this without too much effort into three tables, but is it possible to create a map that will allow all entries to be placed into a single table. The table would look like this:
Code:
EntryId | int <PK>
SiteId | int <FK>
MachineRole | varchar(50)
Message | varchar(50)
Type | varchar(10)
LogTime | DateTime
Is this possible or am I living in a dream?