c# - Edit Row in LINQ -




i trying update row using linq below not doing update reason. have googled , can assure defenitely have primary key in table. below code:

        public static returnedsavedsearchstatus editsavedsearches(eteach.objects.savedsearch savedsearch)     {         returnedsavedsearchstatus rtn = new returnedsavedsearchstatus();         et_tbl_talentpoolsavedsearch dbsavedsearch = new et_tbl_talentpoolsavedsearch();         dbsavedsearch = automapper.mapper.map<et_tbl_talentpoolsavedsearch>(savedsearch);          if (dbsavedsearch.id < 0)         {             rtn.status = false;             rtn.description = "error: id cannot less 0";          }         else         {              using (eteachdatabasedatacontext ctx = new eteachdatabasedatacontext())             {                  var result = ctx.et_tbl_talentpoolsavedsearches.singleordefault(s => s.id == dbsavedsearch.id);                  if (result != null)                 {                     result = dbsavedsearch;                  //   ctx.et_tbl_talentpoolsavedsearches.insertonsubmit(dbsavedsearch);                     ctx.submitchanges();                      rtn.status = true;                     rtn.description = "saved search saved";                 }             }         }          return rtn;     } 

i think problem in assigning entire object, not change object content, changes memory address of object instead (you loosing object), should update each property individually this

result.property1 = dbsavedsearch.property1; result.property2 = dbsavedsearch.property2; ... ... ctx.submitchanges(); 

hope can you





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -