Defining a dictionary field of a data contract

Jun 28, 2008 at 4:54 PM
When I try to create a data contract field and set the collection type to a dictionary (System.Collections.Generic.Dictionary`2[TKey,TValue]) there does not appear to be any way of defining the type of the key. The properties for the field only has a single Type property and this becomes the type of TValue. In the generated code the key is always string.

Is there anyway to define the key type for a dictionary member of a data contract in WSSF?
Jun 30, 2008 at 9:32 PM
Hi, the WSSF v3.0 only works with strings as the key type for Dictionaries out of the box. You could create a custom version of the factory by extending the current one to support this, however in this case a workaround might be a better option. The most smooth one I could advice you to use would be to write a method to generate a string key value based on a certain object.

Jun 30, 2008 at 10:40 PM
Thanks for the response. I suspected they would be my options and I would agree that the workaround you mention is the most productive way forward.