I have created two separate objects, one of class Order and one of class TempOrder. When I try to insert the TempOrder object in the db using db.TempOrders.InsertOnSubmit(obj) and then calling db.SubmitChanges the Order object gets submitted as well (without being attached to the datacontext or anything). There is no relationship between the two objects in the database, but I've created a simple member function in the classes to create Order object when you have the TempOrder and vice versa (toNewOrder - toNewTempOrder). The code I'm using can be seen below:
if(order.PaymentType == "Paypal")
{
TempOrder temp = new TempOrder();
temp = order.ToNewTempOrder();
db.Add(temp);//Add is calling datacontext.TempOrders.InsertOnSubmit and datacontext.SubmitChanges
}
When db.Add(temp) is called the changeset contains the temp object and the order object as well. How can I avoid this? Am I doing anything wrong? Is this because of the function .toNewTempOrder()? I'm stuck on this.