asp.net web api - EF 6 Rollback and Update Best Approach -


i have working solution in place , m initiating thread have discussion on best approach.

environment : ef6, sql 2012 scenario:

i have task , taskdetail table have parent child/relationship through taskid.

create method: while creating task, need ensure entry made in taskdetail table well. first approach: entry made task table. savechanges. taskid , assign dto has information detail table. pass dto taskdetail create method. save changes. commit.. if error occurs, rollback entire transaction

second approach: add relavent fields of task table. add relevant fields of task detail table well. add new detail table object task table through navigation property. task.taskdetail.add(newobj). savechanges.

question 1: both approaches yield same sql. couldnt notice difference though.. best approach doing this???

question 2: also, if take @ scenario, have noticed saveall or savenone approach. tried looping through dbentityentries , rollbacked change. sounds working second approach described above , not first approach since m making save after insertion in order taskid. ended using "dbconexttransaction" introduced in ef 6. best approach???

question 3:

update method:

while doing update , per requirement, not touch task table. deals taskdetail table alone though task id required passed ui.

  • • existing task detail using task id , active flag (there 1 many relationship)
  • update active flag false
  • create new entry in task detail table

i translated above statements code implementation best approach handle it????


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -