c# - MVVM Validation With Entity Framework -


i'm working on project using mvvm , entity framework code first model. implemented idataerrorinfo , inotifypropertychanged in model classes. now, in viewmodel implemented savecommand , cansave boolean method, question how can raise canexecutechanged whole entity , not individual properties? since properties implemented inotifypropertychanged in model.

this model class

 public class guest:validatablebindableclass {     //my properties here     //implement inotifypropertychanged , idataerrorinfo } 

this viewmodelclass:

 public class addeditguestviewmodel:bindableclass {     private hospede guest;     public relaycommand savecommand  { get; set; }     private readonly hmsdb.hms context = new hmsdb.hms();      public hospede guest     {         { return guest; }         set { setproperty(ref guest, value, propertyname: "guest"); }     }      private void onsave()     {          context.hospedes.add(guest);         context.savechanges();     }      private bool cansave()     {         return context.entry(guest)             .getvalidationresult().isvalid;     } } 

you can raise propertychanged event properties passing null or string.empty constructor of propertychangedeventargs:

propertychanged(this, new propertychangedeventargs(null)); 

you need call raisecanexecutechanged() method of each relaycommand though.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -