tags:

views:

189

answers:

0

Hello

I have the following object

[Table("Order")]
public class Order
{

[Column(IsPrimaryKey=true)]
public int id;

public List<OrderItem> _OrderItems;


}

public class OrderItem
{
  public int id;
  public double TotalValue;
}

The OrderItem should be mapped, but not sure how yet - unless I should do it the same and it will just work?! Do I need an association between the two?

They will work using auto generated IDs, so does L2S take care of updating the OrderItem table with the correct Order ID reference? And if I just db.InsertOnSubmit(newOrder) - will this carry the OrderItem objects through to the database also?

I want to be able to submit a new Order, fully populated with child Order Items, to the database.

I can get Order to be created okay, but no idea how to get OrderItems submitted.

Any pointers on how to do this?

Thanks

EDIT: I found the following link which describes basically what I'm trying to do - http://www.onedotnetway.com/insert-master-detail-data-with-linq-to-sql/

However, I don't want to use EntitySets, as I feel this too tightly couples my POCOs to LINQ. I know they have attributes, but I can remove that for Xml Mapping later.

This is a pretty bog standard thing to do, but can't find the answer!