Note that there are some explanatory texts on larger screens.

plurals
  1. POSubsonic:SimpleRepository Parent Child relationship
    text
    copied!<p>I am trying to use the SimpleRepository feature in Subsonic3 - first of all, I must say a big thanks to RobC - Subsonic really rocks, and I can't wait to see additional updates to the SimpleRepository. I am a big fan of the migration approach (developer/class driven rather than starting with the DB).</p> <p>I have had a look at the post here: <a href="https://stackoverflow.com/questions/1378292/parent-and-child-object-in-simplerepository">Parent and Child object in SimpleRepository</a> but I am still a bit confused.</p> <p>If I have got these classes defined:</p> <pre><code>public class Permit { public int PermitID {get; set;} public string Number { get; set; } public DateTime? DateIssued { get; set; } public Product product { get; set; } } public class Product { public int ProductID { get; set; } public string Value { get; set; } } </code></pre> <p>and then I want to save the data for a Permit, what should I be doing? Should I have defined a ProductID in the Permit class, and then programatically link them up? Or should the below code work?</p> <pre><code> var repo = new SimpleRepository("ECPermit", SimpleRepositoryOptions.RunMigrations); var permit = new Permit(); var product = new Product(); permit.Number = "apermit"; permit.DateAdded = DateTime.Now; product.Value = "this is a product"; repo.Add(permit); permit.product = product; repo.Add(product); </code></pre> <p>This is creating the Permit and Product table, but no links between them. What am I doing wrong? Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload