c# - EF - How to edit the below model using linq? -


i'm sending view model data client , update model. know how calling stored procedure, know how using linq queries. appreciated. thanks

[httppost]          public jsonresult editemployee(models.employee employee)           {              try              {                  if (modelstate.isvalid)                  {                      using (emsctx)                      {                          var employeeresults = (from q in emsctx.employees                                                 q.id == employee.id                                                 //code update model.                                                 );                                                    employeedata.employees = employeeresults;                               }                       return json();                  } 

if want update data in db correspoding employee check below edited code:

     [httppost]      public jsonresult editemployee(models.employee employee)       {          try          {              if (modelstate.isvalid)              {                  using (emsctx)                  {                      var employeeresults = (from q in emsctx.employees                                             q.id == employee.id                                              select q                                             ).firstordefault();                              if(employeeresults!=null)                      {                                         employeeresults.column1 = employee.column1;                             employeeresults.column2 = employee.column2;                             employeeresults.column3 = employee.column3;                             employeeresults.column4 = employee.column4;                       }                      emsctx.savechanges();                  }                   return json();              } 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -