tags:

views:

64

answers:

2

Hi. I have something like this:

Order order = new Order();
Item item = new Item();
order.Items.Add(item);
order.Save();

How can I do this with Subsonic? The method that refere to a related table is IQueryable.

+1  A: 

You have three options:

  1. Set the foreign key in Item to the id of your Order object and save both.
  2. Create a partial class which has a method "AddItem", encapsulating this functionality
  3. Modify the T4 templates to allow you to do this automatically; unfortunately this feature doesn't come out of the box yet.

The advantage with Subsonic is that it is flexible, however you occasionally have to fill some of the gaps yourself.

Paul Mason
Thanks Paul.Subsonic's creator, read this post! :)
Fabio
A: 

If you are programming something like a shopping cart you can abstract that out into it's own class that can handle marrying the objects together. I personally think it works better than modify the generated objects.

Mark Fruhling