tags:

views:

118

answers:

1

I have Linq entities which contain non-nullable string properties. I'd like to iterate over the properties, perhaps in the partial OnValidate method, and set those properties to an empty string if they are null.

How can I do this without explicitly writing code for each property by name?

A: 

It is not what you requested, but an alternative could be to use the OnCreated event and to set the properties to string.empty at the time this event is fired already.

That would obviously apply to all uses of the entity, and I am not sure whether such an approach would be sufficient in your case.