This project has moved and is read-only. For the latest updates, please go here.

ConfigurationElementCollection - support composite key

Nov 9, 2011 at 11:00 PM


I've noticed that if you have a ConfigurationElementCollection with "x" number of items and you want the key of the item to be a composite key, this is not currently supported. I worked around it in the following way.

1) disabled the required property on the attribute


2) override PostDeserialize and setup composite key.





3) override the OnRequiredPropertyNotFound to ignore the "key".


Suggestion: allow multiple "key" fields to be selected and under the scenes just concat the values.




However, I still need to remove the xml from the xsd as the intellisense within the config file is indicating to the user that an xml attribute is required for the key.

Aug 21, 2013 at 8:21 PM
I'm struggling with the same issue. I get an error message since the configuration element collection item type has more than one 'key' property. But it seems like it somehow knows that it needs to generate a custom key (it wanted me to code an AutoGeneratedKey property on the type.

I don't quite understand your workaround. Should I mark one of the properties as not a key? What do I need to do in the PostDeserialize and OnRequiredPropertyNotFound overrides (and which class gets the overrides - the configuration element or the configuration element collection)?

Thanks for posting your comments. I am 1.5 days into Configuration Section Designer and the advantages are great, but it seems to be tough to get my old tricks to work.