PDA

View Full Version : [CLOSED] DirectMethod deserializing readonly property



jchau
Jul 17, 2013, 7:48 PM
I have a grid that binds to a collection of Person object. Person has a readonly PersonId that I use to uniquely identify a person. In a directmethod, I pass back the grid's store's records. The directmethod has an argument of type List<Person>. Since PersonId is readonly, it is not being set when deserializing from client JSON data. Therefore, I lost ability to know which person each record is. Is there a workaround? I can not modify the Person object. The property is readonly because it comes from the database as an identity column.

Vladimir
Jul 17, 2013, 8:29 PM
I guess that no workaround because we cannot change property value
What about to create a new class with same set of properties (just empty auto properties with get;set;) and deserialize to that class or deserialize to Dictionary?

jchau
Jul 17, 2013, 8:37 PM
I guess that no workaround because we cannot change property value
What about to create a new class with same set of properties (just empty auto properties with get;set;) and deserialize to that class or deserialize to Dictionary?

We been doing Wrapper classes but that gets cumbersome after awhile. I guess we will keep doing that for now.