i have method aims update monitor profile's nodes , attributes:
all of primitive type of entity (profilename, displayname) updated fine. however, on save changes, attributes , nodes not modified.
here entity itself:
public class nwatchmonprofile { public nwatchmonprofile() { this.casattributes = new hashset<nwatchattribute>(); } [maxlength(50)] public string profilename { get; set; } public system.datetime createddate { get; set; } [maxlength(50)] public string createduser { get; set; } public nullable<system.datetime> endeddate { get; set; } [maxlength(50)] public string endeduser { get; set; } public virtual icollection<nwatchattribute> casattributes { get; set; } public virtual icollection<nwatchnode> nodes { get; set; } }
here mvc controller code being used attempt update record.
var monprofile = new nwatchmonprofile { id = profileid, profilename = profilename, displayname = profilename, casattributes = attributes, nodes = nodes }; monprofile.createddate = datetime.now; monprofile.displayname = profilename; monprofile.profilename = profilename; if (nodes.count > 0) { monprofile.nodes = nodes; } monprofile.casattributes = attributes; var entry = dbcontext.entry(monprofile); entry.state = entitystate.modified; dbcontext.savechanges();
note: have verified "attributes" array contains list of nwatchattributes. ste no longer recommended microsoft.
try this:
dbcontext.entry(monprofile.nodes).state = entitystate.modified; dbcontext.entry(monprofile.casattributes).state = entitystate.modified; dbcontext.entry(monprofile).state = entitystate.modified; dbcontext.savechanges();