Getting error in object assignment
Getting "the property or indexer cannot be used in this context because the set accessor is inaccessible" this error while assigning value to the object variable. How to resolve this error?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ramesh PalaniappanPosted Sep 10, 2016, 8:02 AM
The error message indicates that the property IDis declared like this:
This means that the value of IDcan be read by anyone, but it can only be set from inside instances of DomainObjectand derived classes.
Using SetAssignedIdToisn't an option either, because it requires 5 characters, the ID you want to assign is only two characters long. I assume this method exists to be able to manually assign IDs to rows in a table that normally has an auto-incrementing key. Forcing 5 characters for this ID makes sure - to a certain degree - that the manually assigned keys won't conflict with the automatic created ones.
Rahul ShindayPosted Sep 10, 2016, 8:03 AM