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?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Ramesh PalaniappanRank #370 · 6.8K reputationPosted Sep 10, 2016, 4:02 AM EDT
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 Shinday13 reputationPosted Sep 10, 2016, 4:03 AM EDT