I am new with LightSwitch.
I’m trying to catch event when a checkbox control is being checked.
In the creation of the screen I wrote :
partial void CreateNewEmployee_Created() { this.EmployeeProperty.Contractors = new Contractor(); Dispatchers.Main.BeginInvoke(() => { ((INotifyPropertyChanged) this.EmployeeProperty).PropertyChanged += new PropertyChangedEventHandler(CreateNewEmployee_PropertyChanged); }); }
and handling the event in CreateNewEmployee_PropertyChanged
private void CreateNewEmployee_PropertyChanged(object sender, PropertyChangedEventArgs e) { if(this.EmployeeProperty.IsContractor) { this.EmployeeProperty.Contractors = new Contractor(); } }
I’m getting the excpetion in
this.EmployeeProperty.Contractors = new Contractor();
The exception is
A new instance of the EntityObject class cannot be initialized because
the ambient IDataWorkspace is not available. Please use the
constructor that specifies an EntitySet.
Thanks
Shouldn’t you be using the AddNew() method