Mapping an Array to a Single Row
- by João Bragança
I have the following classes:
public class InventoryItem
{
private Usage[] usages = new Usage[12];
virtual public Usage[] Usages { get { return usages; }}
virtual public string Name{get;set;}
}
public class Usage
{
virtual public double Quantity{get;set;}
virtual public string SomethingElse{get;set;}
}
I know that Usages.Length will always be 12. I think it would be best
to store it in the DB like so:
Name nvarchar(64),
Usage_Quantity_0 float,
Usage_SomethingElse_0 nvarchar(16),
Usage_Quantity_1 float,
Usage_SomethingElse_1 nvarchar(16),
...
Usage_Quantity_11 float,
Usage_SomethingElse_11 nvarchar(16),
How can I get this done?