vb.net - DBContext.ChangeTracker not detecting changes to an Array -
my ef6 project in vb.net maps mysql database using following mapping:
partial public class workrule public property workruleid integer 'maps int public property description string 'maps tinytext public property regulartime byte() 'maps tinyblob end class
if edit description textbox, changes detected , saved expected upon calling .savechanges. however, if edit content of 1 of textboxes bound array element, bound element changed change not detected dbcontext.changetracker , changes not saved database upon calling .savechanges.
i can force save manually setting dbcontext.entry().state=entitystate.modified there better way changes array elements automatically detected? should using other array perhaps?
code follows:
xaml:
<grid> <grid.columndefinitions> <columndefinition width="*"/> <columndefinition width="*"/> </grid.columndefinitions> <listbox x:name="lstworkrules"/> <stackpanel grid.column="1" datacontext="{binding elementname=lstworkrules, path=selecteditem}"> <label>description:</label> <textbox text="{binding path=description}"/> <label>day 1:</label> <textbox text="{binding path=regulartime[0]}"/> <label>day 2:</label> <textbox text="{binding path=regulartime[1]}"/> <label>etc.</label> <button click="button_click">save</button> </stackpanel> </grid>
vb:
imports system.data.entity class mainwindow dim wrcontext workruleentities private sub window_loaded(sender object, e routedeventargs) wrcontext = new workruleentities wrcontext.workrules.load lstworkrules.itemssource = wrcontext.workrules.local lstworkrules.displaymemberpath = "description" end sub private sub button_click(sender object, e routedeventargs) wrcontext.savechanges() end sub end class
Comments
Post a Comment