2

I am new to csla Validation and got a problem to resolve on Validation rules.

The scenario is that I am trying to update a Collection on client on the basis of response from Server.
The Class in which the "notsupported exception" comes is derived from "csla BusinessBase".
While setting a property we have HAsPropertyChanged() method on which an error as insert is an invalid operation and Remove is an Invalid Operation comes.

The Stack Trace is as at Csla.Core.ReadOnlyBindingList1.InsertItem(Int32 index, C item) at System.Collections.ObjectModel.Collection1.Add(T item) at Csla.Validation.BrokenRulesCollection.Add(IRuleMethod rule) at Csla.Validation.ValidationRules.CheckRules(List`1 list) at Csla.Validation.ValidationRules.CheckRules(String propertyName) at Csla.Core.BusinessBase.PropertyHasChanged(String propertyName)

The scenario is not known exactly as for some processes it work and for some response it cannot execute HasPropertyChanged although the value being the same in both cases.
I am not sure of where to implement that method and how. Could you please provide your valuable suggestions.

Shah Faisal
  • 83
  • 1
  • 8

2 Answers2

2

I am not sure if you are still looking for answers but it may help someone who bump into similar issue......Instead of using ReadOnlyBindingList use BusinessBinidngListBase.

ReadOnlyBindingList as name states does not support Add and Remove operation.

Just to make it clear. Insert is invalid operation is not validation error. In your case, validation is passed and CSLA is calling the Insert method of ReadOnlyBindingList which throws invalid operation exception.

Viru
  • 2,228
  • 2
  • 17
  • 28
0

I know this is old, but for others that might have this problem in the future, try "Using SuppressListChangedReadOnlyEvents": for example:

list

secondlist

Using secondlist.SuppressListChangedReadOnlyEvents
  For each item in list
    secondlist.add(item)
  End If
End Using
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77