c# - Database is not effected and in return I get primary key as value of zero -


i want insert these primary keys in other table, or there other easy way add multiple data @ time?

using(dbcontext) {     list<dbtable> dbtbl = new list<dbtbl>();     list<long> retrunedprimarykeys = new list<long>();     for(int i=0; i<datafrompresentationlayer.count;i++)     {       dltable tbl = new dbtable();       tbl.name = datafrompresentationlayer[i].name;       tbl.address = datafrompresentationlayer[i].address       dbtbl.add(tbl);     }     dbcontext.dbtable.insertallonsubmit();     for(int i=0; i< datafrompresentationlayer.count;i++)     {         retrunedprimarykeys.add(dbtbl[i].primarkeycolumn); // here primary keys 0 , in database there not single entry of these record     } } 

you have call submitchanges() method on dbcontext, before read returned values. submitchanges method writes data database.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -