c# - Enity Framework reloading data not working -


after updating entities in different form,i want reload data in grid doesn't seem update.i use:

        private void loaddata()     {         siparisbindingsource.datasource = db.siparis.include("kazan").tolist();     } 

to load data.after openning dialog:

        private void değiştirtoolstripmenuitem_click(object sender, eventargs e)     {         siparis siparis = gridview1.getfocusedrow() siparis;          if (siparis != null)         {             formsiparisaddedit siparisaddedit = new formsiparisaddedit {isedit = true, sipid = siparis.id};             siparisaddedit.showdialog();             loaddata();         }     } 

and changing entities,i try reloading using method,but contents stay same unless close , reopen form.what missing here?

cheers answer,but have problem now,since have made db short lived,i can not detail data,i tried using :

        private void gridview1_masterrowgetchildlist(object sender, devexpress.xtragrid.views.grid.masterrowgetchildlisteventargs e)     {         siparis siparis = (siparis)gridview1.getrow(e.rowhandle);         using (var db = new tank_analizor_dbentities())         {             db.siparis.attach(siparis);             e.childlist = new bindingsource(siparis, "kazan");         }      } 

but

the objectcontext instance has been disposed , can no longer used operations require connection. 

error,if debug it,the child list gets detail data...

your problem appear using static or member data context. should creating new context each time use it. how entity framework designed used.

so change code:

private void loaddata() {     using (var db = new whateveryourcontextnameis()) {         siparisbindingsource.datasource = db.siparis.include("kazan").tolist();     }  } 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -