Mapping an Array to a Single Row
Posted
by João Bragança
on Stack Overflow
See other posts from Stack Overflow
or by João Bragança
Published on 2009-12-09T19:21:14Z
Indexed on
2010/03/27
9:03 UTC
Read the original article
Hit count: 293
nhibernate
|fluent-nhibernate
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?
© Stack Overflow or respective owner