How to persist an object to a db that contains lists of other objects in asp.net?
<p>We have a class <code>X</code>. Class <code>X</code> contains many lists of different types as shown below. All the lists are child tables in the db. </p>

<pre><code>public class X
{
    public List&lt;A&gt; As { get; set; }
    public List&lt;B&gt; Bs { get; set; }
    public List&lt;C&gt; Cs { get; set; }
    public List&lt;D&gt; Ds { get; set; }
    public List&lt;E&gt; Es { get; set; }
}
</code></pre>

<p>My repository takes in an instance of <code>X</code> and needs to persist all lists to the db.</p>

<pre><code>public void Save(X value)
{
    // Save code here
}
</code></pre>

<p>What would be my best option to save all the sub lists? Each type in the list maps to a db table. So there is a table in the db for each <code>A</code>, <code>B</code>, <code>C</code>, <code>D</code>, <code>E</code>.</p>

<p>A method for each table that would save the list. Example: <code>InsertAsById(List&lt;A&gt; values, int id)</code> and so on. Then call that method within the <code>Save()</code>. With this approach, save would look like:</p>

<pre><code>public void Save(X value)
{
    InsertAsById(value.As, value.id);
    InsertBsById(value.Bs, value.id);
    // So on for each list.
}
</code></pre>

<p>We must use ADO.NET. No frameworks.</p>
