c# - I get an error when I want to use EDM Codes in my Windows forms -
i wanted try code program wanted use edm in codes , in visual studio. coded (even save button , etc) there problem whenever want delete record database (which on computer in sql server 2014), error , program crashes , don't know why. can tell me can solve problem? in advance helpful answers.
here code:
 private void btnupdate_click(object sender, eventargs e)  {         if (txtcode.text == "")         {             messagebox.show("code morede nazar ra vared konid");             txtcode.focus();             return;         }          tblfastfood1 w1 = fa.tblfastfood1.firstordefault(x => x.code == convert.toint32(txtcode.text));          if (w1 == null)         {             messagebox.show("chenin codi mojod nist");             txtcode.focus();             return;         }          w1.esm = txtesmmoshtari.text;         w1.address = txtaddress.text;         w1.ghazaasli = combobox1.text;         w1.noshidani = combobox2.text;         w1.salad = combobox3.text;          fa.savechanges();          datagridview1.datasource = fa.tblfastfood1.tolist();     }   here error get:
linq entities not recognize method 'int32 toint32(system.string)' method, , method cannot translated store expression
this can't translated sql, can't used in linq provider (probably linq entities):
convert.toint32(txtcode.text)   instead of using in expression directly, perform operation before linq expression , use resulting value (which can passed sql):
int code = convert.toint32(txtcode.text); tblfastfood1 w1 = fa.tblfastfood1.firstordefault(x => x.code == code);      
Comments
Post a Comment