In here I add some data to database using EF code.When i add using one context it's working.But I need to update another table(another context) using ProductId(productId avaialble in iOdr object.
Here is my code
public int AddorUpdateSalesOrder(ref InvoiceHD iOdr)
{
try
{
if (iOdr.InvoiceId != null)
{
//context.Entry(iOdr).State = EntityState.Modified;
context.InvoiceHDs.Add(iOdr);
//Here I need to update Product context
//using ProductId(it's available in iOdr).
//If ProductId is 1 then I need to
//update product tables ProductQuantity coloumn with new value
}
else
{
context.InvoiceHDs.Add(iOdr);
}
}
catch (Exception ex)
{
string msg = ex.Message;
}
return context.SaveChanges();
}
I have no idea how to do second context.could you please someone give me help for this. thanks