PetaPoco (DotNetNuke) and SQL - Adding an object with a List property or other composite object
I haven't installed DotNetNuke 7 yet, however I examined the source code at codeplex and I think you can do it this way:
public static void AddOrder(Person person){ using (IDataContext context = DataContext.Instance()) { var repositoryPerson = context.GetRepository<Person>(); var repositoryAddrress = context.GetRepository<Address>(); context.BeginTransaction(); try { repositoryPerson.Insert(person); foreach(var address in person.addresses) { repositoryAddress.Insert(address); } context.Commit(); } catch (Exception) { context.RollbackTransaction(); throw; } }}
I haven't tested it so I can't guarantee it works, however this seems right to me.