Insert a record to the master table, retrieve the primary key of the record of the master table, and assign values to multiple records from the table.
Public void createworkordgrid (pp_workord_hd headobject, list <pp_workord_dt> bodyobject) {// method 1 using (VAR transction = project. database. begintransaction () {project. pp_workord_hd.add (headobject); foreach (pp_workord_dt A in bodyobject) {. pp_workord_hd = headobject; project. pp_workord_dt.add (a);} project. savechanges (); transction. commit () ;}// method 2 using (VAR scope = new transactionscope () {project. pp_workord_hd.add (headobject); Project. savechanges (); foreach (pp_workord_dt A in bodyobject) {. pp_workord_hd = headobject; project. pp_workord_dt.add (a);} project. savechanges (); scope. complete ();}}
Insert a record to the master table, retrieve the primary key of the record of the master table, and assign values to multiple records from the table.