Anatoly Lubarsky Logo
MSSQL, .NET, Design. Life and Music

How to Serialize ReadOnly Property

From the forum discussion:


"We have class Class1 which has read-only property ID among others. We have WebService with methods public Class1 GetClass1ByID(int id) and public int SetClass1(Class1 c). The question is how to make this configuration work. Explanation. ID property on the client is a database constraint so we can never give a chance to change it. ReadOnly attribute did not help so as adding an empty setter to the property, ISerializable implementation was simply ignored by the WebService. So how we can solve the problem ?"


Microsoft provides 2 workarounds:


  1. First is "Throwing exception in setter".
  2. Second is "Using WebMethods instead of setter and getter".

The former looks better, but still does not solve the problem 100%.


Related Posts:

Thursday, April 15, 2004 1:46 AM

If your feedback doesn't appear right away, please be patient as it may take a few minutes to publish.

Post a Comment

Protected by CAPTCHAEnter the code you see
Name (*)  
E-mail (*)  
Url
Remember

Comment (*)