Tuesday 15 January 2013

c# - Add to one context and update another context -



c# - Add to one context and update another context -

in here add together info database using ef code.when add together using 1 context it's working.but need update table(another context) using productid(productid avaialble in iodr object.

here code

public int addorupdatesalesorder(ref invoicehd iodr) { seek { if (iodr.invoiceid != null) { //context.entry(iodr).state = entitystate.modified; context.invoicehds.add(iodr); //here need update product context //using productid(it's available in iodr). //if productid 1 need //update product tables productquantity coloumn new value } else { context.invoicehds.add(iodr); } } grab (exception ex) { string msg = ex.message; } homecoming context.savechanges(); }

i have no thought how sec context.could please give me help this. thanks

if reading correctly need create new instance of other context, record need update, update record , savechanges on context.

c# asp.net asp.net-mvc entity-framework

No comments:

Post a Comment